Git – Prune your local branches to keep it in sync with remote branches

On your local branches normally you have a stale branch where it doesn’t have corresponding remote branch and you feel like you want to make it in sync with the remote branches

1. Lets start listing the remote branch first just to know what are the branches available remotely

$ git remote show origin

2. Lets see our local stale branches “–dry-run” command will just display the stale branch but without deleting it

$ git remote prune origin --dry-run

3. Alternatively if you want to really delete the stale branches you can run it without “–dry-run” command

$ git remote prune origin

*just make sure you already committed your feature branch to the remote before doing this

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s