tags:

views:

291

answers:

2
+3  A: 

If you need to get a single file out of a commit that is in your repository then git checkout will do it for you. Specifically:

git checkout <sha> <filename>

will retrieve the file <filename> from the commit <sha> into your current working copy. can be any reference to any commit, so it could be a branch name, a tag name, HEAD^^^^, or anything at all like that that you want...

Graham
"Not just one Class diagram" is the log message for that commit, not the commit ID. You need some way of referencing the commit - such as the SHA1 ID for the commit. git log should be able to give you that.
Graham
Where should I run the command? I updated the error.
Masi
Change into top level of your git directory. Run 'git ls-tree -r --name-only master' to check if the file you want to recover is in 'master' (from included screenshot it looks like 2009-07-27 23:58 state). Run `git checkout master -- <filename>`, where `<filename>` is at it appears in git-ls-tree output
Jakub Narębski
+1  A: 

Do you have an uncorrupted copy of the repository anywhere? If so, pull from there to your working directory and then checkout the file. You can do:

git log --since='2009-07-27 23:58' --pretty=oneline -n 1

to get the hash you want and then get the file via:

git checkout <file> <hash>

If you have no uncorrupted working copies of the repository, you might try 'git fsck', but your chance of success is small or zero if files have been lost.

William Pursell
I added the errors from your command to the question.
Masi