News for hackers. Stuff that matters.
Re:Distrusting git by bennoleslie on Saturday October 01, 2011 @08:22PM (#3061593)
Just to point out that fetch + merge would have caused the same problem. In this case it was a small team, with advance knowledge of what the commit was, so no need to inspect.

But, in any case doing the fetch would have shown that the file was not modified in the fetched tree, and it would have gone ahead and overwritten my changes (without even listing in the merge log that the file was changed).

FWIW, I agree that fetch + (merge | rebase) is in general the best way to go, but I think there is a case when you a pulling in a simple fix from head where doing a pull is legitimate.

After all the documentation says this is a safe operation:

"If any of the remote changes overlap with local uncommitted changes, the merge will be automatically cancelled and the work tree untouched" (from git pull --help).

If this isn't meant to be considered a safe operation git pull should abort if there are any changes to the working directory.

Re:Distrusting git by SomeCallMeTim on Saturday October 01, 2011 @10:20PM (#3061815)
"Safe" or otherwise, it's (IMO) never a good idea to merge uncommitted files.

You're losing history that way: If the merge doesn't actually work, then you've got a screwed up file and no way to roll it back.

It's one of the great strengths of git that you can commit files even if someone else has changed them. It's a bad idea to merge when you have anything significant checked out (I'll leave temporary debugging changes checked out, or very small changes, but that's it). Heck, it's a good idea to check in every few hours, to track changes your making.

Re:Distrusting git by gregors on Sunday October 02, 2011 @11:42AM (#3063086)
Agree 100% I've seen this same type of issue occur in mercurial when people were doing what I call "all or nothing merging". You should not be merging unless you can get to the precise pre-merge state.
Re:Distrusting git by Vitaly on Sunday October 02, 2011 @04:30AM (#3062374)
the real "mistake" here was not doing 'pull' it was doing 'pull' while having uncommitted changes in the working directory. I'd commit or stash before the pull/
Re:Distrusting git by lloeki on Sunday October 02, 2011 @07:05AM (#3062557)
I would have sworn that git would refuse to do git pull with uncommitted local changes.
Re:Distrusting git by mnutt on Sunday October 02, 2011 @12:52PM (#3063294)
It won't let you pull if checked-in files have been modified, but it will let you pull if you have uncommitted new files.