I cloned a Git repository, which contains about five branches. However, when I do git branch
I only see one of them:
$ git branch
* master
Here's something I'd consider robust:
HEAD
to track origin/HEAD
origin
for b in $(git branch -r --format='%(refname:short)'); do
[[ "${b#*/}" = HEAD ]] && continue
git show-ref -q --heads "${b#*/}" || git branch --track "${b#*/}" "$b";
done
git pull --all
It's not necessary to git fetch --all
as passing -all
to git pull
passes this option to the internal fetch
.
Credit to this answer.