Thursday 24 May 2012

[Git] Restore file or directory

Git has a great system to restore a file that you maybe deleted, you can check what is the last commit about the file/directory:

git rev-list -n 1 HEAD -- <file_path>
If you want to restore it you can use this simple command and in a few seconds your file/directory will be back

git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"

No comments:

Post a Comment