Home > OS >  Check, if a commit in branch was cherry-picked into master
Check, if a commit in branch was cherry-picked into master

Time:12-07

Let's suppose, that we have two branches: master and feature_branch Is there a possibility to check, if each commit to the feature_branch was cherry-picked into master?

CodePudding user response:

Yes, there is a way to check if each commit in the feature branch has been cherry-picked into the master branch. One way to do this is by using the git cherry command, which can be used to find which commits in one branch are not present in another branch. For example, you can use the following command to compare the master and feature_branch branches:

git cherry master feature_branch

This will list any commits in the feature_branch branch that have not been cherry-picked into the master branch. If all of the commits in the feature_branch branch have been cherry-picked into the master branch, then the git cherry command will not return any output.

CodePudding user response:

You can use git-log together with the --cherry-pick and --right-only options for that:

git log --cherry-pick --right-only master...feature_branch

This will return the commits in feature_branch that do not have an equivalent1 commit in master. If there's no output, it means that all commits in feature_branch have been cherry-picked into master.


  1. Where by equivalent, we mean a commit whose diff is the same ignoring whitespace and line numbers.
  • Related