Query git reflog for all commits to a specific file

前端 未结 4 638
攒了一身酷
攒了一身酷 2020-12-13 01:43

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

相关标签:
4条回答
  • 2020-12-13 02:05

    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)

    0 讨论(0)
  • 2020-12-13 02:07

    Try:

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

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

    0 讨论(0)
  • 2020-12-13 02:19

    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.

    0 讨论(0)
  • 2020-12-13 02:29

    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
    
    0 讨论(0)
提交回复
热议问题