How do you find who merged a git commit into a branch?

前端 未结 3 1925
生来不讨喜
生来不讨喜 2021-02-20 16:13

There is a file in our git repository in work, I want to find out who merged this file into a branch.

I have the commit hash that identifies the commit (lets say 5

相关标签:
3条回答
  • 2021-02-20 16:46
    git log -1 --merges <hash>
    

    Will show the most recent merge commit log since the <hash> commit (including itself).

    0 讨论(0)
  • 2021-02-20 16:51
    git log <commit-id>..<branch> --ancestry-path --merges --reverse
    

    will give you the list of merges that happened since the <commit-id> that you're interested in and the current state of the <branch>. Depending on your merging workflow, the merge you're interested in may be the first one on the list or one of the next ones.

    It will be helpful to visualize the relevant part of history with

    git log --oneline --graph --decorate --ancestry-path --boundary <commit-id>..<branch>
    

    Look for your <commit-id> near the bottom of the graph (it will belong to "graph boundary" - marked with o rather than *).

    0 讨论(0)
  • 2021-02-20 16:56

    branches

    If I understand you correctly, you have C5, and you are searching for C6. If it's the case, you are probably looking for this:

    git rev-list --merges HEAD --not <hash> --reverse
    

    It will give you the list of merge commits which happened after your hash commit. I use HEAD in this command believing that you are be on master, in the example, or staging in your situation.

    In a not-too-complex environment you are probably looking for the first merge which happened after your commit... But if you have not this kind of chance, You can try:

    git log --graph --decorate HEAD...<hash>^
    

    Or any graphic tool to explore your history (such as gitk)...

    0 讨论(0)
提交回复
热议问题