Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get a list of merges into a branch from the Github website OR API?

In our workflow, no "direct" commits are made into the master branch. The master branch only receives merges from Pull Requests.

We can think of each merge then as a new feature added to the master branch.

So I'd like to get a list of merges into master, as a way to visualize the blocks of features added into the product over time.

Does git or the Github API expose this query, or do I have to parse raw commits?

like image 288
andy Avatar asked Feb 07 '14 09:02

andy


People also ask

How can I see which branches are merged in GitHub?

You can use the git merge-base command to find the latest common commit between the two branches. If that commit is the same as your branch head, then the branch has been completely merged.

How do I see a merged pull request on GitHub?

Under your repository name, click Pull requests. In the "Pull Requests" list, click the pull request you'd like to merge. Depending on the merge options enabled for your repository, you can: Merge all of the commits into the base branch by clicking Merge pull request.


1 Answers

I use the following script:

git log --merges --first-parent master \         --pretty=format:"%h %<(10,trunc)%aN %C(white)%<(15)%ar%Creset %C(red bold)%<(15)%D%Creset %s" 

Explaining each argument:

  • --merges: only "merge" commits (more than 1 parent);
  • --first-parent master: only merges applied to master. This removes the entries where someone merged master into their branches;
  • --pretty-format: applies the following formatting:
    • %h: the commit short hash;
    • %<(10,trunc)%aN: author name, truncated at 10 chars;
    • %<(15)%ar: the relative commit time, padded to 15 chars;
    • %<(15)%D: the tag names, also padded to 15 chars;
    • %s: first line of the commit message.

The result is pretty satisfying:

terminal image of the command output

like image 158
Fábio Batista Avatar answered Sep 20 '22 19:09

Fábio Batista