I faced this problem working on my fork of a repository. When I would make changes to some file(s) on a new branch and then switch to a different branch, git will not raise the error: You have local changes to "X"; cannot switch branches.
error. Instead, it will just move to the new branch and reflect the changes in that branch as well. Please let me know if this a beginner mistake on my part.
Steps to reproduce -
- Fork the repository
- git checkout -b new-branch-name
- Make changes to any file
- Switch back to master and those changes would reflect there
This is causing my master to be the same as a branch that I made changes to, which continued to stay after. Committing once to the newly created branch, however, fixes this issue.