Wednesday, August 15, 2012

git: undo changes, revert uncommitted changes

I mostly love git, but I can never remember the syntax for undoing and reverting things, which is partly because I don't use it that often, and partly because the syntax is un-intuitive. I'll update this post as I hit the various scenarios.
Merge broken by conflicts
Often I'll pull in changes from the stable repo, forgetting I've made some uncommitted local changes, which results in a conflict. To drop all of your local uncommitted changes:
git reset --hard HEAD

1 comment:

Anonymous said...

Extract from my ~/.gitconfig:
[alias]
undo = reset --hard
# HEAD is not needed