If you are a Github user, then you might familiar with Pull Requests. Github has an options to delete a branch after merging of pull request.
After a Pull Request has been merged, you’ll see a button to delete the lingering branch:
Above action will delete the branch only in the remote. Then there is a question: how do I clean up my local branches? I found an answer as follows
Lets say my test branch name
git branch -a shows the test branch
is present on local and also present on remote
git remote prune origin --dry-run lists branches that can be
deleted/pruned on your local. An option
--dry-run is needed.
Now go ahead and actually prune/cleanup the local references by running the command
git remote prune origin. Note that you don't need an option
Again, run the command
git branch -a will show the local status of branches.
Now you can notice that
remotes/origin/feature-collaboration has been removed,
but not the local branch
If wanted, we can clean-up the local branch
feature-collaboration as well
That's it. Have a nice day.