git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 14, 2010, 06:52 UTC
Message-ID
<7v7hpfs8cc.fsf@alter.siamese.dyndns.org>
In-Reply-To
<b4087cc51003120009o7bd99609w996de02b732fbbd9@mail.gmail.com>
Michael Witten <mfwitten@gmail.com> 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".

Previous: Jonathan Nieder
Message 8 of 8 in “How do you switch branches in a bare repo?”
  1. Adam NielsenMar 12, 2010
  2. Johannes SixtMar 12, 2010
  3. Adam NielsenMar 12, 2010
  4. Johannes SixtMar 12, 2010
  5. Adam NielsenMar 12, 2010
  6. Michael WittenMar 12, 2010
  7. Jonathan NiederMar 12, 2010
  8. Junio C HamanoMar 14, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.