repost from confused about git branches and master interaction.
I still don’t get it!
I have 1 branch named ‘miscChanges’ in which I have made changes to some pages (I have not yet committed).Now, when I try to checkout the ‘master’ branch I get the message ‘…files would be overwritten by checkout. blah blah’.
I don’t want to commit my changes on the ‘miscChanges’ branch because I’m not done.
What is the logical way to proceed in this case?
repost from confused about git branches and master interaction . I still don’t get
Share
A branch is just a pointer (reference) to an existing commit ID. Changing the current branch means choosing a different pointer.
This means that uncommitted changes don’t stay on the previous branch, since there’s no place to store these changes. So, when changing branches, git tries to keep these changes in the new code base. To be more specific, any files from the working tree that differ from the last committed state on the old branch will be kept in the working tree after the checkout. But if those files differ between the old and the new branch, git will complain about incompatible changes: it can’t keep the modified file in the working tree since the original file isn’t the same.
There are three ways to solve this:
git commit -a -m tmpgit checkout mastergit checkout miscChangesgit reset HEAD~git commit -a -m tmpgit checkout mastergit checkout miscChangesgit commit --amendgit stash save 'work in progress on branch miscChanges'git checkout mastergit checkout miscChangesgit stash popIf you save more than one stash, you can look up which one should be popped: