Synchronize local GIT with remote deleted branches
Branching is very useful and important feature of any version control system, specially when many developers are working on a single project. Github is one of the popular version control system. In this blog I am giving some useful git commands to update local git with remote deleted branches.
Git provide us two important commands to see the branches:
- All remote branch
git branch -r
- All the branches (remote + local)
git branch -a
If a developer pushes a branch and you use git branch -r command then that branch is shown to you.
But when a developer deletes a branch using command:
git push origin --delete <branchName>
or via github website and you use git branch -r command then still that branch is shown to you. Even if you take pull, your local git will not show that the branch has been deleted.
Following are few git commands that you can use to update your local git with remote deleted branches:
git remote prune origin
git fetch origin --prune
git fetch -p
Hope this helps 🙂