Remove local branches which don't have remote counterparts in Git
Working with Git, it might be the case when you’re working on your feature branch, you worked on it and then pushed it onto the remote.
Now, once it is pushed, you may delete that feature branch from your remote because it’s needed anymore. Over time, this leads to zombie branches scattered around in your local which don’t have any remote-tracking references to them anymore.
So, you might want to delete these branches as well.
Luckily, there is a simple Git command to do this.
$ git fetch origin --prune
Or
$ git fetch origin -p
And that’s it! Running this will remove any remote-tracking references your local that no longer exist on the remote.
Like this article?
Buy me a coffee👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.