Thread (9 messages) 9 messages, 5 authors, 2016-06-15

Re: Find main branch

From: Jeff King <hidden>
Date: 2016-06-15 23:07:45

On Thu, Jan 14, 2016 at 06:40:15PM +0000, pedro rijo wrote:
Stefan Beller solution is based on the server, which may not be very
easy to do when dealing with Github/Bitbucket/Gitlab and other God
knows which provider.

Konstantin ls-remote solution is the one I'm already using, but if I
have several branches on that commit, I will not be able to decide.
Right. Git used to guess, but that was not great exactly because of the
ambiguity you have seen. Servers started publishing the value of the
HEAD symref in git v1.8.4.3. I'd expect that to be available on any
modern server.

There's unfortunately not a plumbing command to directly access the
value, but "git remote set-head $remote -a" will query the remote and
update refs/remotes/$remote/HEAD appropriately. As a bonus, if it's an
older server that doesn't provide the HEAD value, it will fallback to
the "old" heuristics (see guess_remote_head for details).

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help