Forked from sephraim/OLD_git_delete_merged_branches.sh
Created
June 15, 2020 18:19
-
-
Save kudosqujo/ee5c30926a0335066526840d2a9c26fe to your computer and use it in GitHub Desktop.
[Tidy up Git branches] Delete & prune local/remote branches #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
| # Delete remote branches that have been merged into 'origin/develop' (besides current, 'origin/develop' and 'origin/master') | |
| git pull --rebase upstream develop:develop | |
| git push origin develop:develop | |
| git remote prune origin | |
| git branch -r --merged origin/develop | grep -wv 'master\|develop' | sed 's/^origin\///' | xargs -n 1 git push -d origin | |
| git remote prune origin | |
| # Delete local branches that have been merged into 'develop' (besides current, 'develop' and 'master' branches) | |
| git branch --merged develop | grep -wv '\*\|master\|develop' | xargs -n 1 git branch -d |
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 push origin -d LOCAL_BRANCH # remove remote branch tracked by local branch | |
| git remote prune origin # remove *references* (refs/remotes/…) for remote branches | |
| # that no longer exist (run `git branch -a` before and after | |
| # to see the difference. | |
| git branch -d LOCAL_BRANCH # remove branch locally |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment