git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Q] Changing the current branch (HEAD) in a bare repository - how?
@ 2008-06-06 15:43 Brian Foster
  2008-06-06 15:47 ` Johannes Schindelin
  2008-06-06 16:03 ` Jakub Narebski
  0 siblings, 2 replies; 4+ messages in thread
From: Brian Foster @ 2008-06-06 15:43 UTC (permalink / raw)
  To: git

 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.
    $

 I (ultimately) hand-edited `HEAD' (apparently successfully),
 but am wondering what I should have done or may have missed?

 I didn't spot anything in TFM, albeit I could have easily overlooked
 or misunderstood something.

cheers!
	-blf-

-- 
"How many surrealists does it take to   | Brian Foster
 change a lightbulb? Three. One calms   | somewhere in south of France
 the warthog, and two fill the bathtub  | Stop E$$o (ExxonMobil)!
 with brightly-coloured machine tools." | http://www.stopesso.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Q] Changing the current branch (HEAD) in a bare repository - how?
  2008-06-06 15:43 [Q] Changing the current branch (HEAD) in a bare repository - how? Brian Foster
@ 2008-06-06 15:47 ` Johannes Schindelin
  2008-06-06 16:03 ` Jakub Narebski
  1 sibling, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2008-06-06 15:47 UTC (permalink / raw)
  To: Brian Foster; +Cc: git

Hi,

On Fri, 6 Jun 2008, Brian Foster wrote:

>  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'?

vi HEAD

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Q] Changing the current branch (HEAD) in a bare repository - how?
  2008-06-06 15:43 [Q] Changing the current branch (HEAD) in a bare repository - how? Brian Foster
  2008-06-06 15:47 ` Johannes Schindelin
@ 2008-06-06 16:03 ` Jakub Narebski
  1 sibling, 0 replies; 4+ messages in thread
From: Jakub Narebski @ 2008-06-06 16:03 UTC (permalink / raw)
  To: Brian Foster; +Cc: git

"Brian Foster" <brian.foster@innova-card.com> writes:

>  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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Q] Changing the current branch (HEAD) in a bare repository - how?
       [not found] <200806090934.13564.brian.foster@innova-card.com>
@ 2008-06-09  7:50 ` Brian Foster
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Foster @ 2008-06-09  7:50 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Johannes Schindelin

> Date: Friday 06 June 2008
> Subject: Re: [Q] Changing the current branch (HEAD) in a bare repository - how?
> From: Jakub Narebski <jnareb@gmail.com>
>
> "Brian Foster" <brian.foster@innova-card.com> writes:
>>  Using git 1.5.2.5 (Kubuntu 7.10) and a bare repository,
>>  I [ essentially swapped branch names `master' and `foo' ].
>>  Now, how do I change the current branch to the (new)
>>  `master'?  [ ... ]
>
> 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).

Jakub,

 Yes, I also believe that is the case (but have not confirmed).

 The reason for the exercise is the bare repository in question
 will be cloned by newbies, and I want things to "just work"
 out-of-the-box.  The (new) `master' is the development mainline
 (broadly meaning what has passed (usually my) review), and as
 such is nominally what Patches should be generated against.
 (It didn't start out that way due to some convoluted history that
 is not relevant.)  Hence --- with the caveat I'm also rather new
 to git --- it seems wise to ensure the default checked-out branch
 after a clone represents the nominal development line.  (Of course,
 I need/want to encourage the use of topic branches, but I see that
 as a rather different issue.)

>>  I (ultimately) hand-edited `HEAD' [ as Dscho suggested ].
>
> You have to rely on plumbing:
>
>   $ git symbolic-ref HEAD master
>
> (see documentation for details).

 Ah!  Thanks for the hint.

cheers!
	-blf-

-- 
"How many surrealists does it take to   | Brian Foster
 change a lightbulb? Three. One calms   | somewhere in south of France
 the warthog, and two fill the bathtub  |   Stop E$$o (ExxonMobil)!
 with brightly-coloured machine tools." |      http://www.stopesso.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-06-09  7:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-06 15:43 [Q] Changing the current branch (HEAD) in a bare repository - how? Brian Foster
2008-06-06 15:47 ` Johannes Schindelin
2008-06-06 16:03 ` Jakub Narebski
     [not found] <200806090934.13564.brian.foster@innova-card.com>
2008-06-09  7:50 ` Brian Foster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).