When branches are deleted remotely, you need to prune your local repository — the easiest way to do this is with
git fetch -p
This will update your local repository with all the changes made to the remote repository, but without updating any of your local branches. After running this,
git branch --remote
will no longer show the deleted remote branch.
git repositories are complete, whether on your own system or on the server. So when you first clone a repository, you get a complete copy, and your local git “knows” about all the remote branches as well as your local branches. This information isn’t synced automatically, so when your colleague deleted the release
branch on the server, your local git repository didn’t lose its notion of a remote release
branch. Syncing with git fetch
updates all the local information on remote branches so they match the state on the server (strictly speaking, remote repository, wherever that is), but without deleting any local information on remote branches. Pruning with git fetch -p
(or git fetch --prune
, or git remote prune
) removes the local information on remote branches which have been deleted.
git branch --remote
output, after runninggit fetch
? You might need to prune withgit fetch -p
to forget deleted remote branches. – Stephen Kitt May 18 '17 at 14:33git branch --remote
outputorigin/release
. Do you mean to rungit fetch -p
without additional arguments, and will it prune all the deleted remote branches? – Tim May 18 '17 at 14:54git fetch -p
with no additional arguments will prune all the deleted remote branches. – Stephen Kitt May 18 '17 at 15:07git fetch -p
andgit push origin :release
in rudimeier's reply both forget deleted remote branches, except the former prune all and the latter prune the specified branch? – Tim May 18 '17 at 15:11git push origin :release
would do what your coworker probably already did.git fetch -p
is similar togit remote prune origin
in my answer. – rudimeier May 18 '17 at 15:20git push origin :release
delete therelease
branch on GitHub, which I mentioned my coworker already deleted? Dogit fetch -p
andgit remote prune origin
clean up the tracking info within my local repository forrelease
branch? – Tim May 18 '17 at 15:26git push origin :release
deletes the remote branch. It’s not really a good idea in this case, since (a) your colleague has already done that (possibly via the GitHub UI), and (b) if anyone else adds a new branch with the same name on the server, you’ll delete that new branch... – Stephen Kitt May 18 '17 at 15:27