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, :)
git add stages the changes into the index. git commit takes a snapshot of all the tracked files in the index as a commit. A branch is a ref that points to a commit. In your case, the changes are still in the work tree.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With