Skip to content

Instantly share code, notes, and snippets.

@nicholashoule
Last active October 20, 2025 05:34
Show Gist options
  • Select an option

  • Save nicholashoule/ff5a00c8f02ea57f0b26889f022620f4 to your computer and use it in GitHub Desktop.

Select an option

Save nicholashoule/ff5a00c8f02ea57f0b26889f022620f4 to your computer and use it in GitHub Desktop.

Revisions

  1. nicholashoule revised this gist Oct 20, 2025. 1 changed file with 15 additions and 1 deletion.
    16 changes: 15 additions & 1 deletion gitbranches.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,17 @@
    # Git

    ### macOS

    ```Zsh
    brew install git
    ```

    ### Windows

    ```Powershell
    winget install --id Git.Git -e --source winget
    ```

    ## Git prune and delete merged local branches

    ###### Prune
    @@ -10,7 +24,7 @@ git remote prune origin --dry-run
    git remote prune origin
    ```

    ###### Delete (Bash)
    ###### Delete (Bash, Zsh)

    ```
    git branch --merged | grep -v \*
  2. nicholashoule revised this gist Jan 10, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gitbranches.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ## Git prune and delete merged local branches

    ##### Prune
    ###### Prune

    ```
    git remote prune origin --dry-run
  3. nicholashoule revised this gist Jan 10, 2020. 1 changed file with 12 additions and 3 deletions.
    15 changes: 12 additions & 3 deletions gitbranches.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,6 @@

    ##### Prune


    ```
    git remote prune origin --dry-run
    ```
    @@ -11,12 +10,22 @@ git remote prune origin --dry-run
    git remote prune origin
    ```

    ##### Delete
    ###### Delete (Bash)

    ```
    git branch --merged | grep -v \*
    ```

    ```
    git branch --merged | grep -v \* | xargs git branch -D
    ```
    ```

    ###### Delete (Powershell)

    ```
    git branch --merged | Select-String -Pattern '\*' -notMatch
    ```

    ```
    git branch --merged | Select-String -Pattern '\*' -notMatch | % { $_.split()[0] } | % { git branch -D $_ }
    ```
  4. nicholashoule revised this gist Jun 6, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gitbranches.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Git prune and delete merged local branches
    ## Git prune and delete merged local branches

    ##### Prune

  5. nicholashoule renamed this gist Jun 6, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. nicholashoule renamed this gist Jun 6, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. nicholashoule renamed this gist Jun 6, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. nicholashoule revised this gist Jun 6, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Git prune and delete local branches
    # Git prune and delete merged local branches

    ##### Prune

  9. nicholashoule revised this gist Jun 6, 2019. No changes.
  10. nicholashoule revised this gist Jun 6, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Git Prune and Delete local branches
    # Git prune and delete local branches

    ##### Prune

  11. nicholashoule revised this gist Jun 6, 2019. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,6 @@


    ```
    # Test
    git remote prune origin --dry-run
    ```

    @@ -15,7 +14,6 @@ git remote prune origin
    ##### Delete

    ```
    # Test
    git branch --merged | grep -v \*
    ```

  12. nicholashoule revised this gist Jun 6, 2019. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -2,13 +2,20 @@

    ##### Prune


    ```
    # Test
    git remote prune origin --dry-run
    ```

    ```
    git remote prune origin
    ```

    ##### Delete

    ```
    # Test
    git branch --merged | grep -v \*
    ```

  13. nicholashoule revised this gist Jun 6, 2019. No changes.
  14. nicholashoule renamed this gist Jun 6, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  15. nicholashoule revised this gist Jun 6, 2019. No changes.
  16. nicholashoule created this gist Jun 6, 2019.
    17 changes: 17 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # Git Prune and Delete local branches

    ##### Prune

    ```
    git remote prune origin --dry-run
    ```

    ##### Delete

    ```
    git branch --merged | grep -v \*
    ```

    ```
    git branch --merged | grep -v \* | xargs git branch -D
    ```