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

Re: git branch --switch?

From
Alex Riesen <raa.lkml@gmail.com>
Date
Apr 17, 2007, 15:11 UTC
Message-ID
<81b0412b0704170811h510ce0afn1b2277b752bdf422@mail.gmail.com>
In-Reply-To
<F47212AE-B31D-4025-9859-6794E7405DF2@silverinsanity.com>
On 4/17/07, Brian Gernhardt <benji@silverinsanity.com> wrote:
Show 13 quoted lines
>
> On Apr 17, 2007, at 10:21 AM, Alex Riesen wrote:
>
> > Kind of. It can be done with git-read-tree. I.e.:
> >
> >  $ git-read-tree --index-output=.git/tmp-index <branch-name> && \
> >     mv tmp-index .git/index && \
> >     git update-ref HEAD <branch-name>
>
> This does not appear to do what you think it will.  git update-ref
> will write the SHA1 of <branch-name> into the current HEAD, not
> switch HEAD to a new branch.
>

ach, right. Dangerous: it can change the ref HEAD points to. Very sorry! Better just:

 $ rm .git/HEAD && git symbolic-ref HEAD "refs/heads/<branch-name>"

In the end, you just have git-checkout minus git-checkout-index. Maybe a "git-checkout -n" can be useful. Even though I can't imagine what for.

Previous: Brian GernhardtNext: Rene Herman
Message 5 of 18 in “git branch --switch?”
  1. Rene HermanApr 17, 2007
  2. Alex RiesenApr 17, 2007
  3. Rene HermanApr 17, 2007
  4. Brian GernhardtApr 17, 2007
  5. Alex RiesenApr 17, 2007
  6. Rene HermanApr 17, 2007
  7. Brian GernhardtApr 17, 2007
  8. Rene HermanApr 17, 2007
  9. Rene HermanApr 17, 2007
  10. Lars HjemliApr 17, 2007
  11. Rene HermanApr 17, 2007
  12. Randal L. SchwartzApr 17, 2007
  13. Rene HermanApr 17, 2007
  14. Lars HjemliApr 17, 2007
  15. Rene HermanApr 17, 2007
  16. Rene HermanApr 17, 2007
  17. Linus TorvaldsApr 17, 2007
  18. Rene HermanApr 17, 2007

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.