Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a commit has been merged to my current branch - somewhere in time? [duplicate]

I have a random feature/XXXXXXX branch that has some commits and naturally the "develop" branch where those features are eventually merged.

How do I check if a certain old commit (e.g. commit ab123456 from branch feature/user-registration) has been somehow brought/merged to my currently active branch (e.g. develop)? Either by directly merging the feature branch to develop or by going up/merged through some other intermediary branch.

Through git commands or through SourceTree UI, both ways are equally suitable for me.

like image 700
Dzhuneyt Avatar asked Jan 29 '16 15:01

Dzhuneyt


People also ask

How do you check if a commit is merged?

1 answer. You just need to check the length of the `parents`. If there are two or more commits, it's a merge commit, otherwise it's a regular commit.

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.

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

$ git branch -d testing error: The branch 'testing' is not fully merged. If you are sure you want to delete it, run 'git branch -D testing'.


2 Answers

Solution

You can ask git directly, which (local) branches contain your commit, like so:

git branch --contains ab123456

use the "-r" option to query for remote branches, like so:

git branch -r --contains ab123456

References

As Andrew C. comments, this is practically a duplicate of How to list branches that contain a given commit? correctly and elaborately answered by VonC.

Note

I now see that Sulli also provides the same answer in this thread.

like image 131
Ytsen de Boer Avatar answered Oct 01 '22 12:10

Ytsen de Boer


With

git log --oneline devBranch..featureBranch

You see all commits present in featureBranch and not in devBranch

like image 28
Ekans Avatar answered Oct 01 '22 14:10

Ekans