git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* remote branch checkout issue, why its *(no branch)
@ 2008-11-28 22:15 Sudipta GHOSH
  2008-11-28 22:32 ` Jakub Narebski
  0 siblings, 1 reply; 3+ messages in thread
From: Sudipta GHOSH @ 2008-11-28 22:15 UTC (permalink / raw)
  To: git

Hi,

In Our git repository there are few branches like

master
orgin/B1
origin/B2

After doing  #git checkout orgin/B1 I found that my current branch is
*(no branch)

#git branch
*(no branch)
master

Why its showing *(no branch) why not origin/B1

How I can checkout orgin/B1 and after that my current branch will be
orgin/B1 not the *(no branch)

Regards,
-SG

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

* Re: remote branch checkout issue, why its *(no branch)
  2008-11-28 22:15 remote branch checkout issue, why its *(no branch) Sudipta GHOSH
@ 2008-11-28 22:32 ` Jakub Narebski
  2008-11-28 23:24   ` Björn Steinbrink
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Narebski @ 2008-11-28 22:32 UTC (permalink / raw)
  To: Sudipta GHOSH; +Cc: git

"Sudipta GHOSH" <sudipta.in@gmail.com> writes:

> In our git repository there are few branches like
> 
> master
> origin/B1
> origin/B2
> 
> After doing  #git checkout origin/B1 I found that my current branch is
> *(no branch)
> 
> #git branch
> *(no branch)
> master
> 
> Why its showing *(no branch) why not origin/B1
> 
> How I can checkout origin/B1 and after that my current branch will be
> origin/B1 not the *(no branch)

First, 'origin/B1' is so called remote-tracking branch, and its full
name is refs/remotes/origin/B1.  Those branches are updated
_automatically_ by git on fetch, to follow branch 'B1' in 'origin'
repository.  Therefore, to not lose _your_ changes git doesn't allow
checking out remote-tracking branches.  You can checkout _state_ of
such branch into anonymous noname branch, so called in git jargon
"detached HEAD".


What you can do is to create _local_ branch, closely tied to
remote-tracking branch 'origin/B1', by using:

  $ git branch -b B1 --track origin/B1

Git would set up configuration for this branch in such way that "git
pull" command given on 'B1' branch would "do the right thing"(TM)


I really recommend reading "Git User's Manual" or "The Git Community
Book" first...
-- 
Jakub Narebski
Poland
ShadeHawk on #git

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

* Re: remote branch checkout issue, why its *(no branch)
  2008-11-28 22:32 ` Jakub Narebski
@ 2008-11-28 23:24   ` Björn Steinbrink
  0 siblings, 0 replies; 3+ messages in thread
From: Björn Steinbrink @ 2008-11-28 23:24 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: Sudipta GHOSH, git

On 2008.11.28 14:32:56 -0800, Jakub Narebski wrote:
> What you can do is to create _local_ branch, closely tied to
> remote-tracking branch 'origin/B1', by using:
> 
>   $ git branch -b B1 --track origin/B1

You mixed up checkout and branch there ;-)

It's either

git branch B1 origin/B1 # Just create a branch B1

or

git checkout -b B1 origin/B1 # Create and checkout B1

I omitted the "--track" as, by default, it is implied when you create a
new branch from a remote tracking branch.

Björn

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

end of thread, other threads:[~2008-11-28 23:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-28 22:15 remote branch checkout issue, why its *(no branch) Sudipta GHOSH
2008-11-28 22:32 ` Jakub Narebski
2008-11-28 23:24   ` Björn Steinbrink

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