Query git reflog for all commits to a specific file

最后都变了- 提交于 2019-11-27 10:15:48

问题


Is it possible to check the git reflog for all commits to a specific file.

I made a commit to file foo.txt and now it no longer shows in the git history via

git log foo.txt

I want to search the reflog to find all commits to this file so I can find my "lost" commit.


回答1:


Try:

git rev-list --all -- foo.txt

This will give you a list of all commits containing foo.txt.




回答2:


Came across this while searching for an answer, which is simple: git reflog -- $PATH, which will include amends and other actions that will not be visible otherwise (though beware, reflog will be pruned by gc)




回答3:


I'd use:

git rev-list --all --remotes --pretty=oneline foo.txt

The --remotes option lets you use also your remotes, the --pretty=oneline makes it display also the commit message. Very useful when you're looking for a modification pushed to remote in a branch you don't know the name of.



来源:https://stackoverflow.com/questions/6311226/query-git-reflog-for-all-commits-to-a-specific-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!