Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out in which commit a file is removed?

Tags:

git

I got one file removed in the repository. I want to find out on which commit this file is removed. How can I do this?

like image 918
Pan Ruochen Avatar asked Dec 15 '22 15:12

Pan Ruochen


2 Answers

git rev-list -n 1 HEAD -- <file_path>

This will return the hash of the last commit that has modified this path. If your file does not exist in HEAD anymore, it means that it will return the hash of the deleting commit.

Good luck

like image 100
cmc Avatar answered Dec 28 '22 20:12

cmc


git log -p -1 -- <file_path>

It will show the detail of the commit.

like image 28
pktangyue Avatar answered Dec 28 '22 20:12

pktangyue