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

Re: [Q] Changing the current branch (HEAD) in a bare repository - how?

From
Jakub Narebski <jnareb@gmail.com>
Date
Jun 6, 2008, 16:03 UTC
Message-ID
<m3k5h2y2iz.fsf@localhost.localdomain>
In-Reply-To
<a537dd660806060843p4e92932x4e0f5464c5fd1da1@mail.gmail.com>
"Brian Foster" <brian.foster@innova-card.com> writes:
Show 27 quoted lines
>  Using git 1.5.2.5 (Kubuntu 7.10) and a bare repository,
>  I started with (the commands and output below are typed
>  in by hand, mostly from memory):
> 
>     $ git branch -a
>     * master
>       foo
>     $
> 
>  and then changed the branch names:
> 
>     $ git branch -m master old-master
>     $ git branch -m foo master
> 
>  and got this:
> 
>     $ git branch -a
>       master
>     * old-master
>     $
> 
>  Now, how do I change the current branch to the (new)
>  `master'?  A `checkout' fails:
> 
>     $ git checkout master
>     fatal: /usr/bin/git-checkout cannot be used without a working tree.
>     $
In a bare repository it doesn't matter (almost) which branch is
current one (there is no _checked out_ branch, so it only matters as a
default checked out branch for clone, IIRC).
 
>  I (ultimately) hand-edited `HEAD' (apparently successfully),
>  but am wondering what I should have done or may have missed?
You have to rely on plumbing:
  $ git symbolic-ref HEAD master
(see documentation for details).
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Johannes Schindelin
Message 3 of 3 in “[Q] Changing the current branch (HEAD) in a bare repository - how?”
  1. Brian FosterJun 6, 2008
  2. Johannes SchindelinJun 6, 2008
  3. Jakub NarebskiJun 6, 2008

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.