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 --remoteoutput, after runninggit fetch? You might need to prune withgit fetch -pto forget deleted remote branches. – Stephen Kitt May 18 '17 at 14:33git branch --remoteoutputorigin/release. Do you mean to rungit fetch -pwithout additional arguments, and will it prune all the deleted remote branches? – Tim May 18 '17 at 14:54git fetch -pwith no additional arguments will prune all the deleted remote branches. – Stephen Kitt May 18 '17 at 15:07git fetch -pandgit push origin :releasein 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 :releasewould do what your coworker probably already did.git fetch -pis similar togit remote prune originin my answer. – rudimeier May 18 '17 at 15:20git push origin :releasedelete thereleasebranch on GitHub, which I mentioned my coworker already deleted? Dogit fetch -pandgit remote prune originclean up the tracking info within my local repository forreleasebranch? – Tim May 18 '17 at 15:26git push origin :releasedeletes 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