When I run a git clone
to set up a new repo with a remote, I end up with origin/HEAD
that I can use to identify the head of the default branch on origin
without having to first know what the owner of the remote happens to have named it (I've seen both origin
and master
and occupationally both in the same remote).
However if I then add a new remote via git remote add foo ...
the new remote doesn't have a foo/HEAD
, so any attempt to use that to look up the remote's default branch will fail.
Other than manually looking up the default branch for each new remote and adding ${REMOTE}/HEAD
, (and hoping the default branch isn't changed at some later point) is there any way to programmatic find the default branch for a given remote?
(FWIW: I'm using GitPython.)