threads / discuss / 22043

file in new branch also shown in master branch?

Subject: file in new branch also shown in master branch?

## tl;dr

2 messages between Dec 28, 2009 and Dec 28, 2009.

replies: 1people: 2as markdown or json

Carlos Santana· Dec 28, 2009, 22:37 UTC · lore
Hi,
I tried following commands to test branching:

git branch test git checkout test echo "Test branch" >> testfile git status git checkout master git add . git commit git push

The 'testfile' file shows up in 'master' as well as 'test'. I thought it would be seen only in test branch, but it is not so. Is it normal or am I missing something? I was unable to repeat same behavior again, so I am confused now. Any clues?

- CS.

David Aguilar· Dec 28, 2009, 23:25 UTC · re: Carlos Santana · lore

Re: file in new branch also shown in master branch?

On Mon, Dec 28, 2009 at 04:37:08PM -0600, Carlos Santana wrote:
Show 6 quoted lines
> Hi,
> 
> I tried following commands to test branching:
> 
> git branch test
> git checkout test
1. You are now on branch "test"
> echo "Test branch" >> testfile
> git status
2. This does nothing as far as git is concerned.
   "testfile" is still unknown to git.
> git checkout master
3. You are now on branch "master"
> git add .
> git commit
4. You just committed "testfile" to branch "master".
   Recall #3.  This may be where your confusion began.
> The 'testfile' file shows up in 'master' as well as 'test'. I thought
Nope, it only shows up in master.
try:
    git checkout test
It is gone.
> or am I missing something? I was unable to repeat same behavior again,
> so I am confused now. Any clues?
These are great references:

http://book.git-scm.com/3_basic_branching_and_merging.html http://progit.org/book/ch3-0.html

Have fun,
-- 
		David

← back to recent threads