1

Is there a way to know if the code change for a particular commit on a branch is in another branch as well (whether it be via git cherry-pick or merge)

I have two branches of code and occasionally some commits that goes into one branch should also go into another. How do I find out what commit was done to branch A but not B (and vice versa - what's done to both). Right now I am manually checking the commit changes in both branches.

Boon
  • 40,656
  • 60
  • 209
  • 315
  • 2
    `git branch --contains ` lists the branches that contain ``. – jub0bs Jan 26 '15 at 15:59
  • I think searching for the commit message is the only way forward for `cherry-pick`ed commits. Git treats them as separate commits. – Holloway Jan 26 '15 at 16:08
  • If you cherry-picked with `-x` the commit messages of the cherry-picked commits will mention the original hash ID. [More details](http://stackoverflow.com/a/2937724/354577). – ChrisGPT was on strike Jan 26 '15 at 16:25
  • @Jubobs Can't do git branch --contains because some commits are cherry-picked. – Boon Jan 26 '15 at 16:36
  • A particular commit is identified by a unique commit ID. Different commit IDs <=> different commits. You should clarify your question. – jub0bs Jan 26 '15 at 16:38
  • I did clarify by saying it can be done via git cherry-pick. – Boon Jan 26 '15 at 17:11
  • you can see commits that are in branch2 but not in branch1 by: git rev-list branch1..branch2 – manzur Jan 26 '15 at 20:53

1 Answers1

1

The git cherry command will usually do the trick, although it's designed for a slightly different purpose and thus may not be as convenient as you might like.

Read the documentation for git patch-id as well. This should give you some idea of the limitations of this method (in particular if a commit must be modified during cherry-picking, it may look too different afterwards to be found).

Once you have digested both of those (and experimented with them if needed), read the git rev-list documentation and pay attention to the --cherry-mark and --cherry-pick options. Using these with the symmetric difference operator (A...B) will allow you to automate most of what you want here.

torek
  • 448,244
  • 59
  • 642
  • 775