Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [Improvement?] How do you switch branches in a bare repo?

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:48:25

Michael Witten [off-list ref] writes:
The "git checkout" command in a bare repository should serve to select
on which branch other commands (like "git reset") operate, etc.
I am not so sure about the "should" part.

The verb "checkout" is to move/copy something that is stored in somewhere
to some other place, and in the context of git, you are copying out the
contents that is stored in the repository (either the index or the tree of
a commit) to the working tree.  It is true that "git checkout branch" also
switches HEAD while doing so, but that is done primarily so that the
result of further working on the checked out files in the working tree
will be recorded in that branch, but I tend to see that as secondary.
"git checkout file" and "git checkout branch file" do not even touch the
HEAD.

I am more interested in the reason why you need to switch HEAD in a bare
repository to begin with, though.  If it is a one-shot thing, then I don't
think it is too unreasonable to ask for people to learn symbolic-ref; if
some valid workflow requires to flip the HEAD regularly, on the other
hand, we might want to give the command to do so a shorter-to-type name
than symbolic-ref, and that short name could be "checkout".
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help