After making a few changes to branch master
I decided to work from a new branch. I did git checkout -b new_branch_name
and a new branch was created and checked out. git status
showed the changes I had made to master
.
I was curious if my changes were now on both branches (master
and new_branch_name
) or just new_branch_name
. So I checked out master
and noticed my changes were there as well. So I reverted those changes with git checkout -- fileThatChanged
. The changes were indeed gone from master
.
Unfortunately checking out new_branch_name
and running git status
showed my changes were reverted from that branch as well.
I'd like to understand what happened and how can I avoid this in the future.
One solution is to just create/checkout a new branch before starting work.