是否可以检查git reflog以查找特定文件的所有提交。
我提交了文件foo.txt,现在它不再显示在git历史记录中了
git log foo.txt
我想搜索reflog以查找此文件的所有提交,以便找到我的“丢失”提交。
答案 0 :(得分:44)
尝试:
git rev-list --all -- foo.txt
这将为您提供包含foo.txt的所有提交的列表。
答案 1 :(得分:21)
在搜索答案时遇到了这个问题,这很简单:git reflog -- $PATH
,其中包括修改和其他不可见的操作(尽管要注意,reflog将由gc修剪)
答案 2 :(得分:19)
我会用:
git rev-list --all --remotes --pretty=oneline foo.txt
--remotes选项允许你同时使用你的遥控器, - pretty = oneline使它也显示提交消息。当你在一个你不知道名字的分支中寻找一个被推送到远程的修改时非常有用。
答案 3 :(得分:1)
我在使用基准清理历史记录时丢失了一个更改。我使用了类似的方法来搜索reflog:
for r in $(git reflog -- ${file} | cut -d ' ' -f1); do git show ${r}:${file}; done