Skip to main content

Command Palette

Search for a command to run...

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.

Published
1 min read
R

I work at LeSite as Technology Director, where I’m responsible for lead the technical team to building innovative products.

My passion for building software and sharing knowledge brought me to speak in over 14 conferences and create 21 projects used for more than 20,000 developers in the world. Now, I’m focused on helping merchants bringing innovation and technology strategy to their e-commerce ecosystem using the Magento 2, Adobe Commerce, Shopify Plus and other platforms.

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

-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

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!

More from this blog

R

Rafael Corrêa Gomes - Ecommerce Developer

31 posts

Escrevo sobre desenvolvimento, e-commerce, Shopify, Magento, produtividade e carreira profissional.