1

I have inherited a repo with five or six branches that are not merged into master, and I have to figure out what is in them. I have been using SourceTree to get a graphical view of the branching relationships.

Unfortunately, it looks like a LOT of commits have been cherry-picked from branch A to branches B and C, while others from branch C got picked into A, but not B. And then, of course, a lot of them got cherry picked into master. So ... there is no clear history or provenance, at least with any tool or log option I know of, and I really have no good way to determine what has made it into the master branch.

The good thing is that the cherry-pick preserves the commit message, and the ones I've spot checked, if the message matches the content of the commit matches. My current plan of attack involves checking out each branch in turn, oing a git log with the format --format="ts=%ci;sha=%h;lbl=%d;c=%s" into a file named with the branch name. Then writing a perl script to go through each and every commit message, grep it from all of the branch-named files, to produce a list of the branches that commit appears in.

Unless there is some visualization tool that draws lines between cherry-picked commits in divergent branches? That would be really helpful right about now. Maybe a log format code that indicates that this commit was cherry-picked from that commit, maybe showing the sha of the origin commit. Heck, just a mark that this was a cherry-picked commit instead of a manual one would help me identify which ones I need to look at!

Does anybody have any other suggestions on how to reconcile the commit histories when so much cherry picking has been going on?

rimiha
  • 57
  • 5

1 Answers1

0

Try git cherry foo bar.

The command lists all the commits reachable from bar. If a commit has been applied to foo, there is a leading - sign. If it has not, there is a leading + sign.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53