0

I'm pretty new to using Git so I may just not understand this properly, however I can't seem to find an answer.

When working on a branch off master when I make changes on the new branch then switch back to master using:

$git checkout master

My changes are being carried over to the master branch without me committing and merging or even staging the changes.

I thought it was not supposed to be possible to switch branches without committing or stashing the changes.

  • 1
    Are this new files? if yes: http://stackoverflow.com/questions/12341665/git-new-file-appears-in-all-branches – Rumid Mar 07 '17 at 16:57
  • It is not a new file. It is a file that was created on the master branch then edited on another branch – Scotty B Mar 07 '17 at 19:07
  • Then I am curious. Could you check 'git log' to make sure you committed on right branch? – Rumid Mar 07 '17 at 19:36
  • One more thing. It was created when you were on master. Did you commit this file on master? Go to your newer branch and make 'git diff master ' please. – Rumid Mar 07 '17 at 19:44
  • It is created on master, then a new branch is created so all the files from master are carried over on to the new branch. The issue is that I then start editing the files on the new branch I would then go to the master branch without staging or committing my new changes, which as I understand git should not allow me to switch branches. Instead it is bringing the changes over to the master. – Scotty B Mar 07 '17 at 21:38
  • I think you know already the answer as this question is marked as a duplicate. Didn't know that it is possible! – Rumid Mar 08 '17 at 07:02

0 Answers0