Home > Software design >  Github, how to get commit Id of first commit within pull request?
Github, how to get commit Id of first commit within pull request?

Time:10-30

Let's say someone opens a pull request from a feature branch to dev branch. This pull request contains one commit (0d636ac). Later on this someone commits X amount of times to the feature branch, all these commits get synced to the pull request.

How can I get/reference of the first commit within the pull request (0d636ac)?

Visual: b0 is where the feature-branch gets created from a1

a0 --- a1
        \
         b0 --- ,..., --- bN

I want the commit id of b0

CodePudding user response:

Try git log a1..bN --reverse -n 1. This should give you the hash of the first commit present in bN which is not present in a1.

git log a..b displays commits between a and b.

--reverse makes it start at the first commit instead of the last one.

-n 1 limits the output to a single commit.

See https://git-scm.com/docs/git-log#_commit_limiting for details.

  • Related