Using git branch --all
shows all remote and local branches. When does Git refresh this list?
On pull/push? And how do I refresh it using Git Bash?
git pull updates your current local working branch, and all of the remote tracking branches.
The git branch -r command is sufficient if you want a brief overview of all the branches stored on a remote. If you want more detailed information, the git remote show command may be more useful. This command returns: All remote branches.
The "git branch -D" command will fail for current branch, but every other branch will get wiped.
To update the local list of remote branches:
git remote update origin --prune
To show all local and remote branches that (local) Git knows about
git branch -a
The OP did not ask for cleanup for all remotes, rather for all branches of default remote.
So git fetch --prune
is what should be used.
Setting git config remote.origin.prune true
makes --prune
automatic. In that case just git fetch
will also prune stale remote branches from the local copy. See also Automatic prune with Git fetch or pull.
Note that this does not clean local branches that are no longer tracking a remote branch. See How to prune local tracking branches that do not exist on remote anymore for that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With