Search code examples
gitcrashrestore

Restoring a file from Git?


The question is related to the question "How to restore Git after fatal file system error?", but for a single file.

I need to get to last state 2009-07-27 23:58, where I need the file:

/Users/henri/BAckup/6-relationdiagram/Normalized_perhaps_DB/simple_schema0.tcuml

How can I restore the file after a crash?

ADDED: Where will I find the file? What are they supposed to do?

Graham's tip

$git checkout 63c6844fded9cfcdee14c9330be82557046b3e56 HENRI_suunnittelu_doc/6-relaatiotietokantakaavio/Normalized_perhaps_DB/simple_schema0.tcuml

William's tip

git checkout bee6763b55cf8259438aa575cedbb09d1d02b96a  HENRI_suunnittelu_doc/6-relaatiotietokantakaavio/Normalized_perhaps_DB/simple_schema0.tcuml

Solution

  • sometimes i delete a file or directory in my git local and i want to restore just that file. i run the following command:

     git checkout -- filenameOrDirectory
    

    note the spaces in between.