DEV Community

Rafael Corrêa Gomes
Rafael Corrêa Gomes

Posted on • Updated on • Originally published at blog.rafaelcg.com

 

How to remove local branches that aren't on remote?

This is the perfect method when you want to synchronize your local repository branches with your remote branches.

Sync your branches

You just need to use the option -p or --prune during the fetch command.

git fetch --prune
Enter fullscreen mode Exit fullscreen mode

-p, --prune
After fetching, remove any remote-tracking branches which no longer exist on the remote. You can check the prune options too.

Clean your local

If you want synchronize not just the branches, you can synchronize the current branch too, just using this commands below.

git pull --all
git reset --hard
git clean -df
Enter fullscreen mode Exit fullscreen mode

Thank you

Thank you for reading this article, I hope that it was useful for you.
If you use a different strategy let me know below!

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.