Let's say I've staged a file, and then I'm working on that file and want to abandon those changes and pull the copy down from the stage again.

How do I do that?

I tried git reset HEAD but for some reason it unstages the file and keeps my changes in the working dir.

git init; echo A>A; git add A; git commit -m A; echo AA>>A; git add A; echo AAA>>A
git diff A | patch -R -p1

There is probably an easier way, but this works.

And so there is:

git show :A > A

Even easier. I assumed this got it from HEAD, but I was wrong there.

git checkout A

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.