I was working on a git branch and was ready to commit my changes, so I made a commit with a useful commit message. I then absentmindedly made minor changes to the code that are not worth keeping. I now want to change branches, but git gives me,
error: You have local changes to "X"; cannot switch branches.
Can I change branches without committing? If so, how can I set this up? If not, how do I get out of this problem? I want to ignore the minor changes without committing and just change branches.
error: You have local changes to '<filename>'; cannot switch branches.
and branch will not change. you can dogit checkout -m <branch-name>
to merge conflicts and checkout to the branch and resolve conflicts yourself, orgit checkout -f <branch-name>
to ignore changes. – samad montazeri