Skip to content

Instantly share code, notes, and snippets.

@c50
Last active September 1, 2021 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c50/54b07dcdb2fd2376eb9a8caf79ac0672 to your computer and use it in GitHub Desktop.
Save c50/54b07dcdb2fd2376eb9a8caf79ac0672 to your computer and use it in GitHub Desktop.
Git delete locally all remote branches that are gone remotely
git fetch -p && for branch in $(git branch -vv | grep ': gone]' | awk '{print $1}'); do git branch -D $branch; done
@c50
Copy link
Author

c50 commented Sep 1, 2021

This may differ when your terminal has different language settings. You can check it first typing this:

git branch -vv

e.g. in french you may then need to adapt "gone" to its French translation "disparue".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment