I am having an issue with Git branching. Whenever I make changes to a branch, all those changes get reflected in master branch even though I haven’t invoked explicit merge command.
For example,
I created a “dashboard” branch git checkout -b dashboard
then I have made changes in one of my file(say routes.rb) and now I switched to master git checkout master
Now when I open routes.rb, i can see the changes from dashboard branch. Why? Do I have some git settings that should not be there?
When you make changes, those changes only exist in your working tree up until to the point when you commit them.
When you switch branches, Git will carry changes in your worktree over to the new checkout. This is often helpful when you notice that you were working on the wrong branch.
There’s even a recent discussion about this “unexpected” behavior on the Git mailing list about this. To quote Junio:
Edit
Just in case if above link becomes void
Problem
Reply