Query git reflog for all commits to a specific fil

2019-01-21 21:56发布

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.

标签: git reflog
3条回答
戒情不戒烟
2楼-- · 2019-01-21 22:31

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.

查看更多
爷的心禁止访问
3楼-- · 2019-01-21 22:32

Try:

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

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

查看更多
干净又极端
4楼-- · 2019-01-21 22:38

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)

查看更多
登录 后发表回答