Search code examples
gitgitlabgit-mergepull-request

How to obtain the list of commits of merged GitLab merge requests?


I'm working on a GitLab repo that has fast forward merge requests enabled, i.e. each merge request's individual commits are just linearly appended to the master branch's history. Now for e.g. a git bisect run it might make sense to only consider the commits that finish each merge request, but is there any way to obtain the list of those commits?

As an example, consider the MRs !1 consisting of commits A1->B1 and !2 (A2->B2->C2). The commit history thus becomes

A1 -> B1 -> A2 -> B2 -> C2

Is there any way to obtain the list B1,C2 other than manually checking the merge requests?


Solution

  • As described on https://docs.gitlab.com/ee/user/project/merge_requests/reviewing_and_managing_merge_requests.html#checkout-locally-by-modifying-gitconfig-for-a-given-repository, one can add the line

    fetch = +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*
    

    to .git/config. Now all merge requests are available as branches in the origin/merge-requests/ namespace.