Trying to move an SVN repository to git, I discovered a couple of interesting facts:
git clone
does not really clone.
It only copies one branch, so the resulting repository is not identical to the original. Creating a real clone with all branches is possible, but it requires adding a local branch for each remote branch:
branch --track somename origin/somename
Beware of counterfeits: if you do branch --track somename (bad)
or branch -track origin/somename origin/somename (bad)
, this won’t do what you want. Also, you will get an error if you will try to track an already tracked branch like master
.
git pull --all
and git push --all
are not symmetrical
git pull --all
means “all remotes”. It pulls a single branch from all remotes (and it looks like it pulls tags as well). A typical repository has exactly one remote called “origin”.
git push --all
means “all branches”. It pushes all branches to a single remote. To add to the confusion, it does not push tags.
As far as I can tell, there is no way to tell “pull” to pull all branches, as well as there is no way to tell “push” to push to all remotes.
git pull does not remove references to deleted remote branches
Let’s say you pulled a branch foo
from origin, and then someone else deleted it from the remote repository. Your local repository will still have a dangling reference to origin/foo
. Pulling from origin does not change anything. To get rid of the dangling reference you must cast a special spell:
git remote prune origin
Fun stuff!