LWN.net Logo

Can "git clone" checkout a specified branch now?

Can "git clone" checkout a specified branch now?

Posted Aug 6, 2008 18:13 UTC (Wed) by iabervon (subscriber, #722)
In reply to: Can "git clone" checkout a specified branch now? by bbbush
Parent article: Git Magic

No, but it should be pretty easy to add now. In builtin-clone, around line 491, it looks up
what HEAD points to on the remote repository, with remote_head being the "HEAD is <hash>" info
and head_points_at being the "refs/heads/master is <hash>" info (where the left part of that
is what HEAD is determined to be a reference to), if there is one. Just look up the user's
specified branch for both if the option was used instead of using locate_head() to find them.

(head_points_at is used so that you get a local branch with the same name as the remote
branch, if the remote repository doesn't have HEAD not on a branch; remote_head is used so
that you check out whatever tree it was that the remote had as HEAD, regardless of whether it
was a branch or not.)


(Log in to post comments)

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds