简体   繁体   中英

How to recover deleted files with git on moved folder

Several months ago I did a refactoring of paths to several java modules. Now it seems that I have forgotten to move the src/test directory of one of the modules and instead deleted it...

How can I recover all these deleted files? Note that the path to the module where the files was located, is deleted, and I cannot remember the earlier path?

As explained in this answer you can find the last commit where the file/folder was modified with this command:

git log --full-history -- src/test

Once you find the commit where the file exists you can checkout it into your current working tree with as explained here :

git checkout <SHA>^ -- <path-to-file>

Note that <SHA> is the hash of the commit where the folder was deleted, so you make a checkout to the previous commit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM