是否可以检查 git reflog 是否有对特定文件的所有提交。
我对文件 foo.txt 进行了提交,现在它不再显示在 git 历史记录中
git log foo.txt
我想搜索 reflog 以找到对该文件的所有提交,以便找到我的“丢失”提交。
在寻找答案时遇到了这个问题,这很简单:git reflog -- $PATH
,其中将包括修改和其他不可见的操作(但要注意,reflog 将被 gc 修剪)
尝试:
git rev-list --all -- foo.txt
这将为您提供包含 foo.txt 的所有提交的列表。
我会使用:
git rev-list --all --remotes --pretty=oneline foo.txt
--remotes 选项让你也可以使用你的遥控器, --pretty=oneline 让它也显示提交消息。当您在不知道名称的分支中寻找推送到远程的修改时非常有用。
I lost a change when I was cleaning up my history with rebase. I used something like this to search the reflogs:
for r in $(git reflog -- ${file} | cut -d ' ' -f1); do git show ${r}:${file}; done