tags:

views:

1878

answers:

2

I wonder why isn't it implemented in the GUI? I know git has a content approach vs. single file approach but sometimes single file reverting is crucial.

For instance an .png graphics file from a few commits before is needed.

Probably I need to do a checkout but I'm still not sure as the concepts sometimes escape me.

+10  A: 

If you know how many commits back you need to go, you can use:

git checkout master~5 image.png

This assumes that you're on the master branch, and the version you want is 5 commits back.

Ron DeVera
You can use HEAD~5 rather than master~5 if you're not on the master branch.
hallidave
Am I right to think that HEAD^ or master^ goes back just 1 commit?
dylanfm
@dylanfm, that's right.
Ron DeVera
+11  A: 

To expand on Ron DeVera's post, where he mentions master~5, you can use any reference to a git commit, including the SHA-1 if that's most convenient. The point is that the command looks like this:

git checkout [commit-ref] [filename]

foxxtrot
Thanks that's useful especially if one doesn't want look for branch names or count how many commits etc.
keepyourliberty