GIT – remove unused branches

If you have some branche son your remote repository that are no longer in use you can delete them by following the steps below (make sure no one is updating these branches anymore).

First make sure you are not on the branch you want to delete

git checkout master

Then list the branches (remote and local) defined in your local repository

git branch -a

Now delete the branch with name CompanyEntity (casesensitive) from local if its (still) there

# Delete local
git branch -d CompanyEntity
# Deltete remote
git push origin --delete CompanyEntity

Now to update the branches for a repository at another location (deleting stale branches) execute the command:

git fetch --prune

The local branches will be synced with the remote branches

Share

Leave a Reply

Your email address will not be published. Required fields are marked *