Created
May 8, 2024 09:52
-
-
Save dmelechow/18c174b5f8d919a6fddb23c954837167 to your computer and use it in GitHub Desktop.
git commands for working with branches history
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
| # Remove all megred branches locally | |
| git branch --merged | grep -v "\*" | xargs -n 1 git branch -d | |
| # Remove all local branch if there is no origin version. (It means remote branch was merged and removed) | |
| for local_branch in $(git branch); | |
| do | |
| if ! git branch -r | grep "origin/$local_branch" &>/dev/null; then | |
| git branch -D "$local_branch" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment