I had run this command with misunderstandings while I was deleting my one local branch,
git branch -D branch-name
git fetch -p
but I have
The other answers explain what git fetch --prune
does, but there is one case where it needs to be a bit more precise: when the there is nothing to fetch (no new refs) from the upstream repo.
In that case, it does prune the remote tracking branches (from /remotes/anUpstreamRepo/*
), but it didn't say what upstream repo was the cause of said pruning.
This is fixed by commit 4b3b33a by Tom Miller (tmiller) for git 1.9/2.0 (Q1 2014):
fetch --prune
: always print header urlIf "
fetch --prune
" is run with no new refs to fetch, but it has refs to prune. Then, the header url is not printed as it would if there were new refs to fetch.Output before this patch:
$ git fetch --prune remote-with-no-new-refs
x [deleted] (none) -> origin/world
Output after this patch:
$ git fetch --prune remote-with-no-new-refs
From https://github.com/git/git
x [deleted] (none) -> origin/test