Reputation: 360
I am still in the process of learning Git and when I felt I have mastered it all..I encounter a problem which makes me feel a novice again...
I have a master and a branch.For some 'God only knows' reason when I perform "Git status" on both the branches they are showing the same changes.
And when I commit these changes to one of them..I don't see them in the other..
Master*: Git status
On branch Master
Changes not staged for commit:
modified: Config/A.txt
Untracked files:
logs/B.txt
**Branch-1*: Git status**
On branch Branch-1
Changes not staged for commit:
modified: Config/A.txt
Untracked files:
logs/B.txt
you be the God,for a while, :)
Upvotes: 8
Views: 5084
Reputation: 30317
I guess you are switching from one branch to the other and running status, right? When you have uncommitted changes on your work tree and you ask git to switch, git will bring over the changes to the other branch you check out (at least, it tries to). There are some checks it performs and if the changes can't be applied correctly on the other branch, the switch is interrupted.
The check is actually very simple. If the files that are modified in the working tree are different between HEAD
[1] and where you want to go, the checkout is not allowed to take place. If the modified files are the same between HEAD
and where you want to go, then git carries out the checkout keeping those files as they are on the working tree.
[1] Notice I am specifying HEAD
, a.k.a. "the commit that you are on", not "the working tree".
Upvotes: 10
Reputation: 71
If you don't make a commit and you go to checkout master (or other branch) git will show you the same changes in both branch. But when you do the commit, these changes won't show for git in other branch, just in the branch where you are working.
Upvotes: 6