Re:Distrusting git
by EdiX on Saturday October 01, 2011 @01:00PM
(#3060429)
Normally in git you never pull on a dirty working dir, you either stash or commit your work and then pull. That's why this bug is unlikely to trigger normally.
[ Parent
| on HN ]
Re:Distrusting git
by bobwaycott on Saturday October 01, 2011 @04:35PM
(#3061036)
Exactly what I was thinking. I'd have done:
git fetch
git stash
git pull --rebase branch-name
git stash apply
All this cp business struck me as a bit of not understanding how to properly work with git. I've never had my work clobbered by following the strategy above. But I also don't go very long between commits on my working branch.Your workflow is a little overcomplicated.. I think the following will produce identical results:
git pull --rebase branch-name
He is using "git stash" to create a commit object for his uncommitted changes, giving him more documentation in the event that Something Goes Wrong. Git will never throw away your data, but you might get into a weird mental state and type a command that throws away your data. By creating a commit object, you can always get back to that state, and you have a little one-line note-to-self that helps you not get into a weird mental state.
I personally do a "real" commit before rebase, but "git stash" is really the exact same thing. I guess "git stash pop" is less scary than "git rebase HEAD^". Either way, you can always undo that operation via the reflog.