Restore Deleted Files In Git
2012-03-30 16:55
302 查看
Ever been working on a project for a while, then go work on something else, then come back after a few weeks? Sure you have.
Ever come back and somebody deleted your nice nginx config file you had in there for your local dev server? Ever wonder where the hell it went? Well wonder no more!
I had this happen a couple days ago. Somebody deleted my
This prints the summary of all commits that have deletes. Awesome. Now you can look through in which commit your file was deleted.
And that will restore your file. Rinse and repeat for multiple files.
Note: the file name is Case sensitive
demo:
http://verboselogging.com/2010/10/19/restore-deleted-files-in-git
Ever come back and somebody deleted your nice nginx config file you had in there for your local dev server? Ever wonder where the hell it went? Well wonder no more!
I had this happen a couple days ago. Somebody deleted my
nginx.conffile. It was just gone.
Find it!
First things first, I had to find the file. A little bit of Googling1 and looking at git docs, I found this:git log --diff-filter=D --summary
This prints the summary of all commits that have deletes. Awesome. Now you can look through in which commit your file was deleted.
Restore it!
Once you have that, you can use the commit hash in the next command:git checkout <COMMIT>^ -- <file>
And that will restore your file. Rinse and repeat for multiple files.
Note: the file name is Case sensitive
demo:
http://verboselogging.com/2010/10/19/restore-deleted-files-in-git
相关文章推荐
- Restore a deleted file in a Git repo
- git - Restore locally deleted files with git
- How do I commit all deleted files in Git?
- Git how to restore deleted files
- How to restore deleted user accounts and their group memberships in Active Directory
- Git skills in reseting files
- How to .gitignore all files/folder in a folder, but not the folder itself?
- git Staging Deleted files
- How can I recover a file that I deleted in my local repo from the remote repo in Git?
- Git崩溃, Android studio崩溃 “Too many open files in system”
- git ignore已经checked in files
- How to restore the deleted panel in Ubuntu
- check how many files are added or modified or deleted by git command and python
- Git CMD - checkout: Switch branches or restore working tree files
- git ignore已经checked in files
- How to restore an element that has been deleted in CCRC?
- git revert回退时提示One or more files are in a conflicted state
- git remove files which have been deleted
- git checkout to restore local deleted file
- How to restore deleted user accounts and their group memberships in Active Directory