Git: Unexpected behaviour?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Unexpected git behaviour

---
# First create a local git repo

$mkdir gitexample
$git config --global user.name "my name"
$git config --global user.email "me@xxxxxx"
$git init
$git add .
$git commit -m 'initial commit'

# Create/Edit an empty file
$vi readme.txt

# add a single line: "this was added in the master branch."
$git commit -a

# create and checkout a new branch (from master)
$git branch test
$git checkout test

# edit the readme.txt file and do not commit
# add the text:  "this was added in the test branch.", save and exit
$vi readme.txt

#now switch back to master
$git checkout master
$cat readme.txt

#You will see both lines in the master.  

Question #1:
	Why was this line added in the *master branch?


--- even further surprising
In the master branch, now do a commit
$git commit -a

cat readme.txt ( you will see the line in the master now that was added in
the test branch )

Question #2:
	Why did this happen?

# Now switch back to the test branch
$git checkout test
$cat readme.txt

You will only see the one line: "This was added in the master branch"

Question #3:
	Why did this happen?

and NOT the line added in that branch: "this was added in the test branch"
<= this line is gone

What is the reason for this?

1) Why do I see uncommitted changes in the branches made off master in the
master branch?
2) Why, if I commit them in the master, do the disappear in the branch in
which they were made?

This is confusing, I would think the * master branch would be left
untouched.  This would solve issue #2.


--
View this message in context: http://git.661346.n2.nabble.com/Git-Unexpected-behaviour-tp6986736p6986736.html
Sent from the git mailing list archive at Nabble.com.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]