Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine when branch was merged into another

Tags:

git

I've got a small git repo with multimple branches in in

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

git branch --merged

But I also need to determine when and who did this

UPDATE ON USING git log --merges

For example i have two branches

  • master
  • 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

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

like image 598
Anton Avatar asked Mar 20 '17 07:03

Anton


People also ask

How will you know in git If a branch has been already merged into master Mcq?

To know if a branch has been merged into master or not you can use the below commands: git branch --merged – It lists the branches that have been merged into the current branch. git branch --no-merged – It lists the branches that have not been merged.

Which git command is used to check if a branch has not been merged into master?

With git branch --merged <commit> , your local list of branches will be filtered by all the branches who have been merged into a given branch or commit. Similar to above, you could type git branch --no-merged <commit> and only the branches not merged into the named commit would be listed.

What happens to a branch once it has been merged into another?

When you perform a merge, you effectively merge one branch into another—typically a feature branch or bug fix branch into a main branch such as master or develop. Not only will the code changes get merged in, but also all the commits that went into the feature branch.


1 Answers

You can use git log for that.

While one 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
like image 133
AnimiVulpis Avatar answered Sep 21 '22 23:09

AnimiVulpis