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
$ 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.
👋 Hi there! I'm Amit. I write articles about all things web development. If you like what I write and want me to continue doing the same, I would like you buy me some coffees. I'd highly appreciate that. Cheers!