Last active
May 17, 2022 16:58
-
-
Save alexleone/e77cd07590c7004886b2e3b3e0dd1013 to your computer and use it in GitHub Desktop.
[Git Delete All Local Branches Not On Origin] #git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git remote prune origin prunes tracking branches not on the remote. | |
git branch --merged lists branches that have been merged into the current branch. | |
xargs git branch -d deletes branches listed on standard input. | |
Be careful deleting branches listed by git branch --merged. The list could include master or other branches you'd prefer not to delete. | |
To give yourself the opportunity to edit the list before deleting branches, you could do the following in one line: | |
git branch --merged >/tmp/merged-branches && \ | |
vi /tmp/merged-branches && xargs git branch -d </tmp/merged-branches |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment