0

I have a file on master branch, I have then created a new branch new and wrote a few print statements. I then checkout onto master, and the same changes are on master aswell. I have not pushed the changes from new.

How is that possible?

CutePoison
  • 4,679
  • 5
  • 28
  • 63
  • Are there any actual committed changes to that file between master and new? If switching between branches doesn't introduce changes to files you have modified, it will leave the file untouched and will still contain your modifications. – Jeff Mercado Jul 23 '20 at 06:27
  • Why would it contain modifications on another branch than the one I'm working on ? – CutePoison Jul 23 '20 at 06:34
  • Esp. this answer: https://stackoverflow.com/a/246298/7976758 – phd Jul 23 '20 at 06:43

1 Answers1

0

Because most likely you have not committed your changes to the new branch.

Rather they are just dangling around in an uncommitted, possibly unstaged state.

Type git status to confirm this theory. Also, at any given point switch back to the new branch via git checkout new and then type git log or git log -p (-p is to view changes in the commit) to see if you have committed your work on the new branch.

David
  • 2,715
  • 2
  • 22
  • 31