Okay so I am new to using git..and I thought I understood the concept of branching, but now I am confused.
Lets say I have a master.
I create a branch called bra
Although you were in branch1 when you made the changes, those changes are not really "in" branch1 until you commit them.
From $ git help checkout
:
Local modifications to the files in the working tree are kept, so that they can be committed to the
.
If, on the other hand, you commit your changes to branch1 before switching back to master, then when you $ git checkout master
, git will revert the files in your working directory back to the snapshot that master points to, as you are expecting.
If for some reason you really want to avoid committing your changes to branch1, but still work on a different branch without those changes, you might consider using $ git stash
to stash your changes, then switch to your new branch and do the work you need to, then switch back to branch1 and do $ git stash pop
to get back your stashed changes.