Finding a branch point with Git?

前端 未结 22 1548
小鲜肉
小鲜肉 2020-11-22 10:11

I have a repository with branches master and A and lots of merge activity between the two. How can I find the commit in my repository when branch A was created based on mast

22条回答
  •  执笔经年
    2020-11-22 10:57

    I seem to be getting some joy with

    git rev-list branch...master
    

    The last line you get is the first commit on the branch, so then it's a matter of getting the parent of that. So

    git rev-list -1 `git rev-list branch...master | tail -1`^
    

    Seems to work for me and doesn't need diffs and so on (which is helpful as we don't have that version of diff)

    Correction: This doesn't work if you are on the master branch, but I'm doing this in a script so that's less of an issue

提交回复
热议问题