threads / discuss / 1686

question git & branches

Subject: question git & branches

## tl;dr

7 messages between Aug 29, 2005 and Aug 29, 2005.

replies: 6people: 5as markdown or json

Ben Greear· Aug 29, 2005, 08:07 UTC · lore
Hello!
I've been trying out git and have some questions...

I installed the latest snapshot of git, pulled down the kernel (2.6.13-rc7), and started hacking. What fun...got myself a git patch and was happy.

Then, decided I wanted to branch off my changes from the main tree so I could maintain the patch-set separate for this particular feature.

I created a new branch 'ben_dev_rfcnt'.
Now, I also have another patch that I wanted to pull into git.
Before merging this, I created another branch 'foo'.

I changed to this branch foo and imported my patch and resolved the conflicts, etc.

I think I'm missing something fundamental though... I wanted to change to the ben_dev_rfcnt branch to build a kernel without my additional patch. git branch ben_dev_rfcnt seems to change it fine, but all of the changes for repository 'foo' are also still here.

Am I completely missing how branches work, or just missing a few commands?

Thanks, Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com
Martin Langhoff· Aug 29, 2005, 11:27 UTC · re: Ben Greear · lore

Re: question git & branches

On 8/29/05, Ben Greear <greearb@candelatech.com> wrote:
Show 8 quoted lines
> I created a new branch 'ben_dev_rfcnt'.
> 
> Now, I also have another patch that I wanted to pull into git.
> 
> Before merging this, I created another branch 'foo'.
> 
> I changed to this branch foo and imported my patch and resolved the
> conflicts, etc.

Are you using git-checkout to change branches? If you have cogito installed, cg-status is a good, handy way of confirming you are where you expect to be.

You can also do git-show-branch{,es-script}
cheers,
martin
Alex Riesen· Aug 29, 2005, 12:15 UTC · re: Ben Greear · lore

Re: question git & branches

On 8/29/05, Ben Greear <greearb@candelatech.com> wrote:
Show 5 quoted lines
> I think I'm missing something fundamental though...  I wanted to
> change to the ben_dev_rfcnt branch to build a kernel without my
> additional patch.  git branch ben_dev_rfcnt seems to change
> it fine, but all of the changes for repository 'foo' are also
> still here.

You probably looking for "get reset --hard master", which should bring the working tree in sync with cache, but being new to git myself, I'm not sure.

Linus Torvalds· Aug 29, 2005, 15:03 UTC · re: Ben Greear · lore

Re: question git & branches

On Mon, 29 Aug 2005, Ben Greear wrote:
Show 6 quoted lines
> 
> I think I'm missing something fundamental though...  I wanted to
> change to the ben_dev_rfcnt branch to build a kernel without my
> additional patch.  git branch ben_dev_rfcnt seems to change
> it fine, but all of the changes for repository 'foo' are also
> still here.

"git branch" just creates the branch, it doesn't actually do anything else. Use "git checkout <branchname>" to switch to it.

You can do both with "bit checkout -b <branchname>" which both creates the branch and switches to it.

(Both "git branch" and "git checkout -b <branchname>" that reate a new branch take an optional argument which says what point you want the branch to start at. It defaults to "current state", but you can create a branch at any point in the history by just explicitly stating the commit name that you want to start off with as the head of the branch)

Use "gitk --all" to visualize where the different branches are in the history, and a plain "git branch" with no arguments to list the branches and mark your currently active branch.

				Linus
Ben Greear· Aug 29, 2005, 17:49 UTC · re: Linus Torvalds · lore

Re: question git & branches

Linus Torvalds wrote:
Show 12 quoted lines
> 
> On Mon, 29 Aug 2005, Ben Greear wrote:
> 
>>I think I'm missing something fundamental though...  I wanted to
>>change to the ben_dev_rfcnt branch to build a kernel without my
>>additional patch.  git branch ben_dev_rfcnt seems to change
>>it fine, but all of the changes for repository 'foo' are also
>>still here.
> 
> 
> "git branch" just creates the branch, it doesn't actually do anything
> else. Use "git checkout <branchname>" to switch to it.

I tried 'git checkout ben_dev_rfcnt'. It took a few seconds and had no errors. But, the files created on my other branch still exist in the code tree, and I still see my patch in the existing files.. I would expect them to go away.

I don't think I've managed to commit anything to any branch yet... Could that be part of the problem?

I tried gitk -all, and get this error popup:
Gitk: error reading commits: bad arguments to git-rev-list.
(Note: arguments to gitk are passed to
git-rev-list
to allow selection of commits to be displayed.)

Thanks, Ben

Show 19 quoted lines
> You can do both with "bit checkout -b <branchname>" which both creates the 
> branch and switches to it.
> 
> (Both "git branch" and "git checkout -b <branchname>" that reate a new
> branch take an optional argument which says what point you want the branch
> to start at. It defaults to "current state", but you can create a branch
> at any point in the history by just explicitly stating the commit name
> that you want to start off with as the head of the branch)
> 
> Use "gitk --all" to visualize where the different branches are in the 
> history, and a plain "git branch" with no arguments to list the branches 
> and mark your currently active branch.
> 
> 				Linus
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com
Linus Torvalds· Aug 29, 2005, 18:04 UTC · re: Ben Greear · lore

Re: question git & branches

On Mon, 29 Aug 2005, Ben Greear wrote:
Show 8 quoted lines
> 
> I tried 'git checkout ben_dev_rfcnt'.  It took a few seconds and
> had no errors.  But, the files created on my other branch still
> exist in the code tree, and I still see my patch in the
> existing files..  I would expect them to go away.
> 
> I don't think I've managed to commit anything to any branch yet...  Could that
> be part of the problem?

Yes. If you haven't committed anything, then the dirty state follows you to the other branch (unless the branch differs in the dirty files, in which case "git checkout" will refuse with a hopefully quite understandable error message).

> I tried gitk -all, and get this error popup:
Double dashes: "gitk --all".
		Linus
Jon Loeliger· Aug 29, 2005, 20:20 UTC · re: Linus Torvalds · lore

Re: question git & branches

On Mon, 2005-08-29 at 10:03, Linus Torvalds wrote:
> (Both "git branch" and "git checkout -b <branchname>" that reate a new

This of course, is Git's answer to the long standing UNIX tradition. Whereas UNIX would creat() files, Git will reate() branches.

> 				Linus
jdl

← back to recent threads