Skip to content
On this page

An image

ray.so

Git Sync Local Branches With Remote

The git fetch --prune command is used in the Git version control system to update your local repository with changes from a remote repository while also removing any references to remote branches that have been deleted on the remote.

sh
git fetch --prune

I have the following local branches:

An image

While remote branches are:

An image

Now, the magic moment: When you use git fetch --prune:

An image

Observe how local branches are now synchronized with the remote:

An image

That's the secret recipe—keeping things neat and tidy in your local repo 😉.

Last updated: