Search code examples
gitgitlabgitlab-api

How can I see all the opened merge requests in GitLab using a command?


Is there a git command that can show all the opened merge requests for a repository? I've found how I can see all the branches that were merged into master using: git log --merges --first-parent master \ --pretty=format:"%h %<(10,trunc)%aN %C(white)%<(15)%ar%Creset %C(red bold)%<(15)%D%Creset %s", but this is not what I'm looking for.


Solution

  • Using the tips phd gave me, I've found this command that helped me see all the opened merge request for a single branch that I want:

    curl -k --header "PRIVATE-TOKEN: TOKEN" "https://gitlabhost.com/api/v4/merge_requests?scope=all&state=opened&source_branch=source_branch" > ROOTDIR/opened_merge_requests.txt
    

    Considering TOKEN, source_branch and ROOTDIR to be string variables.