I am working on a git repository with a master branch and another the topic branch. I have switched to topic branch and modified a file. Now, if I switched to the master branch, that same file is shown as modified.
For example:
git status in git-build branch:
# On branch git-build # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: cvsup_current #
Switch to master branch
[root@redbull builder_scripts (git-build)]# git co master M builder_scripts/cvsup_current Switched to branch "master"
git status in master branch
[root@redbull builder_scripts (master)]# git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: cvsup_current #
Why is that the file is shown as modified in the master branch even though it was modified in git-build branch?
My understanding was that the branches are independent of each other and when I change from one branch to another the changes do not "spill over" from one branch to another. So I am obviously missing something here.
Has anyone got a clue stick?
This is the default behaviour of git.
You can use -f flag to checkout to do ‘clean checkout’ if you like.