I find this to be annoying because I would like to quickly switch branches and do something and then switch back to what I was working on before. I realize I can stash and t
You could use git checkout
's --merge
(-m
) option.
Using it causes a three-way merge to be done when switching branches. You may need to resolve merge conflicts if these occur.
As to why this occurs, the manual states
When switching branches, if you have local modifications to one or more files that are different between the current branch and the branch to which you are switching, the command refuses to switch branches in order to preserve your modifications in context.
See the git checkout manual page for more details