Remove Local Branches No Longer On Remote



Usually when a development branch gets merged with the master branch and then deleted remotely you will still be able to see it locally. Therefore, you no longer need to keep such hanging branches locally and you might want to clean that up.

One way of cleaning branches that no longer exist on remote is by executing the following command:

$ git remote prune origin

Then if you execute $ git branch -vv you will notice that beside the branch that has been deleted remotely now it says gone.
Now you can delete those branches directly using the following command:

$ git branch -D <branch_name>



Done


Leave a comment


Post


Comments

Be the first one to leave a comment!