Kyaw Soe Hein
Kyaw Soe Hein

Reputation: 87

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

Upvotes: 2

Views: 88

Answers (2)

Bhuneshwer
Bhuneshwer

Reputation: 587

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

git reset --hard <commitId>

example - git reset --hard 0e3e0e85727f02ff1d23a42bdb994cb2ff7326dc

This should be fine

Upvotes: 0

Simon J. Liu
Simon J. Liu

Reputation: 827

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

Upvotes: 1

Related Questions