2

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

2 Answers2

1

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
Simon J. Liu
  • 787
  • 4
  • 11
  • What does a/ and b/ mean? – Kyaw Soe Hein Dec 24 '16 at 08:47
  • And can u explain me about the color difference mean which are green and purple, I think. Thank u so much – Kyaw Soe Hein Dec 24 '16 at 08:48
  • green is added lines/files. red is deleted lines/files – pedrorijo91 Dec 24 '16 at 09:17
  • The line start with '+' means this line is added line.The line start with '-' means this line is deleted line. check this https://www.gnu.org/software/diffutils/manual/html_node/Unified-Format.html and https://en.wikipedia.org/wiki/Diff_utility#Unified_format and http://stackoverflow.com/questions/2529441/how-to-read-the-output-from-git-diff – Simon J. Liu Dec 24 '16 at 09:28
0

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

git reset --hard <commitId>

example - git reset --hard 0e3e0e85727f02ff1d23a42bdb994cb2ff7326dc

This should be fine

Bhuneshwer
  • 577
  • 1
  • 9
  • 26