Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git command to find what branches were merged into current branch and when

I have several feature branches that are being automatically merged into the integration branch. I'd like to know if and when this is happening.

I can type git log which will show me that a merge has happened but for some reason it does not show me from which feature branch it just says "merged integration_branch into integration_branch"

I can type git branch --merged

but that only lists the feature branches that are being merged into the integration branch. I'd like to know when and by whom, and be able to drill down into this merge information.

like image 961
Randnum Avatar asked Jan 07 '13 22:01

Randnum


People also ask

How do you check if a branch was merged into another branch?

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.

What happens when two branches are merged in git?

Merging Branches. Once you've completed work on your branch, it is time to merge it into the main branch. Merging takes your branch changes and implements them into the main branch. Depending on the commit history, Git performs merges two ways: fast-forward and three-way merge.

What happens when branches are merged?

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.

When a branch is merged with the main line is it automatically deleted?

You can have head branches automatically deleted after pull requests are merged in your repository. Anyone with admin permissions to a repository can enable or disable the automatic deletion of branches.


1 Answers

I would make use of git log with some colours to do this:

git log --graph --full-history --all --color \ 
--pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"

This will colour each branch and the merges. It will also label the head of each branch.

You can add relative dates and committer names with this:

git log --graph --full-history --all --color \
--pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s \
%Cgreen(%cr) %C(bold blue)<%an>%Creset'"

For more info see: http://git-scm.com/book/en/Git-Basics-Viewing-the-Commit-History

like image 111
Ilion Avatar answered Sep 28 '22 05:09

Ilion