在Git中查找何时删除文件 [英] Find when a file was deleted in Git

查看:94
本文介绍了在Git中查找何时删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个我需要的文件,而这个文件曾经存放在版本库中,而且我突然寻找并认为哦!那个文件去了哪里?



是否有一系列Git命令会告诉我文件really_needed.txt是否在提交n-13时被删除?



换句话说,没有看每一个单独的提交,并且知道我的Git repo每个文件都有变化,快速找到最后一个提交的文件,所以我可以把它恢复?

> git log - [文件路径] 显示文件的更改,即使该文件被删除也能正常工作。

  git log -1  -  [文件路径] 

请参阅哪个提交已删除文件


I have a Git repository with n commits.

I have a file that I need, and that used to be in the repository, and that I suddenly look for and think "Oh! Where'd that file go?"

Is there a (series of) Git command(s) that will tell me that "file really_needed.txt was deleted at commit n-13"?

In other words, without looking at every individual commit, and knowing that my Git repo has every change of every file, can I quickly find the last commit that HAS that file, so I can get it back?

解决方案

git log -- [file path] shows the changes of a file, work even if the file was deleted.

git log -1 -- [file path]

See Which commit deleted a file

这篇关于在Git中查找何时删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆