I have a master and a development branch, both pushed to GitHub. I\'ve cloned, pulled, and fetched, but I re
The accepted answer of git branch -a only shows the remote branches. If you attempt to checkout the branches you'll be unable to unless you still have network access to the origin server.
If you’re looking for a self-contained clone or backup that includes all remote branches and commit logs, use:
git clone http://user@repo.url
git pull --all
Credit: Gabe Kopley's for suggesting using git pull --all.
Note:
Of course, if you no longer have network access to the remote/origin server, remote/origin branches will not have any updates reflected in them. Their revisions will reflect commits from the date and time you performed the 2 commands above.
To checkout ALL your clone branches to local branches with one command, use one of the bash commands below:
$ for i in $(git branch -a |grep 'remotes' | awk -F/ '{print $3}' \
| grep -v 'HEAD ->');do git checkout -b $i --track origin/$i; done
OR
If your repo has nested branches then this command will take that into account:
for i in $(git branch -a |grep 'remotes' |grep -v 'HEAD ->');do \
basename ${i##\./} | xargs -I {} git checkout -b {} --track origin/{}; done