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

RE: Head, Branch != Head -> Branch?

From
mattr94@gmail.com <mattr94@gmail.com>
Date
Dec 14, 2019, 22:41 UTC
Message-ID
<007401d5b2cf$ac787ed0$05697c70$@gmail.com>
In-Reply-To
<CAE3VKEppVv=rocJU7jHKu7i=dLyaHhpauTBmm91udjZ_DOpW+g@mail.gmail.com>

After going through the code and thinking about this. I think the unexpected results came from git branch not checking out the branch I created. I know git checkout -b master would have been the result I wanted. If I were to create another commit with HEAD checked out instead of master, master would not update, only HEAD would.

> I guess the real crime here is that git branch does not checkout the branch created. I don't think I ever wanted to create a branch without checking it out, otherwise I would use git tag.
The problem with this is that git tag doesn't create a new branch, but rather just a new tag so running something like:

git tag my-tag git checkout my-tag git add . git commit -m "message"

wouldn't update my-tag either, you would need to create a new branch for that.  Sometimes I want to create a branch without checking it out, as I'm sure many other users do.  Is it an issue of documentation where maybe the behavior isn't clear? It does specifically say this in the description of git branch, but to be fair it is buried 6 paragraphs in
Previous: Tomas ZubiriNext: Tomas Zubiri
Message 3 of 5 in “Head, Branch != Head -> Branch?”
  1. Tomas ZubiriDec 14, 2019
  2. Tomas ZubiriDec 14, 2019
  3. mattr94@gmail.comDec 14, 2019
  4. Tomas ZubiriDec 15, 2019
  5. Joshua TevesDec 15, 2019

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.