![]() Or prune individual remote tracking branches, as the other answer suggests, with: git branch -dr branchname Once you delete the branch from the remote, you can prune to get rid of remote tracking branches with: git remote prune origin Git push origin :branchname # for really old git To delete it from the remote use: git push -delete origin branchname If it's not merged, use: git branch -D branchname You can delete a merged local branch with: git branch -d branchname You can see that master and dev are excluded in case they are an ancestor. To delete all local branches that are already merged into the currently checked out branch: git branch -merged | egrep -v "(^\*|master|main|dev)" | xargs git branch -d git branch -merged| egrep -v "(^\*|master|main|dev|skip_branch_name)" The branch skip_branch_name will not be deleted. If you want to skip, you can add it to the egrep command like the following. git branch -merged| egrep -v "(^\*|master|main|dev)" ![]() The following command will skip master branch and anything that has dev in it. We can add few arguments to skip important branches that we don't want to delete like master or a develop. You might see few branches you don't want to remove. Usually I branch off of a "sprint-start" tag and master, dev and qa are not ancestors.įirst, list locally-tracking branches that were merged in remote (consider using -r flag to list all remote-tracking branches). ![]() NOTE: You can add other branches to exclude like master and dev if your workflow has those as a possible ancestor.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |