简体   繁体   中英

How can I recover the file I deleted in git

I am totally beginner to git. Now, my problem is I like to recover the file my friend deleted. I have the commit for it and it hasn't been pushed up yet. I have tried revert, rest, summary etc and they don't work for me. Help me out.

I don't remember the filename. So I like to know how to check the things done in a commit either. Please help me. Here is the commit's SHA

commit 0e3e0e85727f02ff1d23a42bdb994cb2ff7326dc

Following command will show all the changes in this commit, including your file.

git show 0e3e0e85727f02ff1d23a42bdb994cb2ff7326dc

or check out the commit to a new branch, then you can find the file in branch tmp

git checkout 0e3e0e85727f02ff1d23a42bdb994cb2ff7326dc -b tmp

If you want to reset till last commit you can do:

git reset --hard <commitId>

example - git reset --hard 0e3e0e85727f02ff1d23a42bdb994cb2ff7326dc

This should be fine

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