Re: [BUG] git checkout <branch> allowed with uncommitted changes
From: PJ Weisberg <hidden>
Date: 2016-06-15 22:52:15
On Thu, Oct 13, 2011 at 8:53 AM, arQon [off-list ref] wrote:
quoted
git co mastererror: Your local changes to the following files would be overwritten by checkout: file1.txt Please, commit your changes or stash them before you can switch branches. Aborting I'm sure if I thought about it enough (ie re-read Andreas's post a couple more times) I'd be able to understand why git gets it right sometimes but not other times, but I'm too tired right now. Even when I *am* awake and
Git gets it "right" (by your definition) when file1.txt on one branch is different from file1.txt on the other branch. That means that switching branches would require changing the file, so it refuses to overwrite your changes by doing so. If it CAN switch branches without losing your changes, it does. The fundamental problem is that you're thinking of the changes to the working tree (which aren't commited) as being "on" some branch. Until they're committed, changes in the working tree are only in the working tree. That's basically the difference between "committed" and "not committed". -PJ