# git branch

4 messages from 2011-05-23 to 2011-05-23. Participants: Gergely Buday, Marcus Karlsson, Tim Mazid.
Thread: https://gitlist.dev/t/27435

## Gergely Buday, 2011-05-23 11:36

Subject: git branch
Message-ID: <BANLkTinzped82Njnw4ZUeHY6Qu4R4hKK-w@mail.gmail.com>
URL: https://gitlist.dev/e/BANLkTinzped82Njnw4ZUeHY6Qu4R4hKK-w%40mail.gmail.com

```
Hi there,

I created

git branch install_2.0

for my install script. Then pushed to

git push origin install_2.0

so that github stores by branch

after another commit I tried to push again but git told me that I'm
not on that branch. Why git loses the state that I'm on a branch? What
should I do to have my expected behaviour?

- Gergely

```

## Marcus Karlsson, 2011-05-23 11:46

Subject: Re: git branch
Message-ID: <20110523114633.GE7387@kennedy.acc.umu.se>
URL: https://gitlist.dev/e/20110523114633.GE7387%40kennedy.acc.umu.se
In-Reply-To: <BANLkTinzped82Njnw4ZUeHY6Qu4R4hKK-w@mail.gmail.com>

```
On Mon, May 23, 2011 at 01:36:09PM +0200, Gergely Buday wrote:
> Hi there,
> 
> I created
> 
> git branch install_2.0
> 
> for my install script. Then pushed to
> 
> git push origin install_2.0
> 
> so that github stores by branch
> 
> after another commit I tried to push again but git told me that I'm
> not on that branch. Why git loses the state that I'm on a branch? What
> should I do to have my expected behaviour?
> 
> - Gergely

I'm not sure if I'm following you correctly, but with Git you need to
check out your branch after creating it. Run git checkout install_2.0
after you have created it.

	Marcus

```

## Gergely Buday, 2011-05-23 12:17

Subject: Re: git branch
Message-ID: <BANLkTim_L0M2oFV383+5n7-X_KQTdd3BAg@mail.gmail.com>
URL: https://gitlist.dev/e/BANLkTim_L0M2oFV383%2B5n7-X_KQTdd3BAg%40mail.gmail.com
In-Reply-To: <20110523114633.GE7387@kennedy.acc.umu.se>

```
> I'm not sure if I'm following you correctly, but with Git you need to
> check out your branch after creating it. Run git checkout install_2.0
> after you have created it.

Yes, that sounds reasonable. I did not know it was necessary to "switch to it".

- Gergely

```

## Tim Mazid, 2011-05-23 12:36

Subject: RE: git branch
Message-ID: <SNT124-W21FCFAE653C2B81DD980BFC4720@phx.gbl>
URL: https://gitlist.dev/e/SNT124-W21FCFAE653C2B81DD980BFC4720%40phx.gbl
In-Reply-To: <BANLkTim_L0M2oFV383+5n7-X_KQTdd3BAg@mail.gmail.com>

```

> From: gbuday@gmail.com
>
> > I'm not sure if I'm following you correctly, but with Git you need to
> > check out your branch after creating it. Run git checkout install_2.0
> > after you have created it.
>
> Yes, that sounds reasonable. I did not know it was necessary to "switch to it".
>
> - Gergely


Hi Gergely,

The way that git branches work is that they "point" at commits.
When you do a "git commit", git updates the branch to point at
the new commit you just created. In this way, you can have a
multitude of branches and be working on only one at a time.

N.B. If you want to create a branch and "switch" (checkout) to
it at once, you can pass the "-b" option to checkout, thus:
"git checkout -b new-branch-name"; this will create a new branch
named "new-branch-name" and immediately switch to it.


Tim.

() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
 		 	   		  
```
