It usually happens to me that I make some local changes, only to discover that I made it on the wrong branch, so I need to switch branch before committing. The problem is that I cannot switch branch when there are local changes. Is there anyway to do that?
Obviously, I can copy the updated files, switch branch, then copy them back, but this doesn’t really seem clever!
You can switch branches while you have local modifications unless your local changes conflict with the difference between the two branches. In this case you can use the
-mor--mergeoption tocheckoutto perform the checkout anyway and perform a merge betwee changes and the changes caused by switching branches.