Anton
Anton

Reputation: 1030

Determine when branch was merged into another

I've got a small git repo with multiple branches.

I need to determine when and who has merged particular branch to master. I use this command to see merged branches:

git branch --merged

But I also need to determine when and who did this.

For example I have two branches, master and release/1.

Execution of git log --merges gives me

commit 430c9e85e527ab1a63693265e220a8c72ed2fd14
Merge: c5ce3bffc 3ce4f8bff
Author: author1
Date:   Thu Feb 23 07:15:55 2017 +0300

    Merge branch 'master'

commit a909cf5d0100ef1621965f1f4275bd05c1495427
Merge: c2a2a4430 bfda36db3
Author: author1
Date:   Thu Feb 23 05:41:32 2017 +0300

    Merge branch 'feature/3'

commit c5ce3bffc4bde8dc60ae264781e9c990e67daaa1
Merge: 4107e0817 b03ef505f
Author: author2
Date:   Tue Feb 21 11:00:56 2017 +0300

    Merge branch 'release/1' of https://tfs.awesomecode.com/EpicSystems/_git/EPC into release/1

commit b03ef505f177eaf82a31164a97daa1d63c4146f8
Merge: 3f9b75bb7 0ee5e531d
Author: author1
Date:   Tue Feb 21 09:20:31 2017 +0300

    Merge branch 'release/1' of https://tfs.awesomecode.com/epicsystems/_git/EPC

I do not quite understand what the last two commits from log do. It's not obvious which one merged release/1 into master.

Upvotes: 6

Views: 3239

Answers (1)

AnimiVulpis
AnimiVulpis

Reputation: 2726

You can use git log for that.

While on the master branch perform a

$ git log --merges

to see a log of all merges into master.


In order to get a better visual understanding of what is going on try out git log --decorate --oneline --graph

  • --decorate will add annotations to the log entries showing informations like HEAD and which branch tip this particular commit represents e.g. origin/release/1
  • oneline will produce a more concise representation. Every commit will only show the subject line (you can obviously omit this, but I find it easier to understand the graph this way)
  • graph will print a graphical representation of your commit history with * representing commits and lines to indicate the parents of a particular commit

The graph will show the newest commit at the top


From here on it's guesswork because I don't know how the history of your repository evolved, but I guess the following:

  • I don't really know what the last commit means, because it seems to be missing the into part
  • The second commit (from the bottom) might come from conflicts between author2 changes to the release/1 branch while other changes where made to the same branch. This resulted in the merge of feature/1 into feature/1 (some kind of git rebase maybe)
  • Then feature/3 was merged
  • Then the master branch was merged

Upvotes: 5

Related Questions