6

Context : We are a team of programmer who work on a project with severals branches :

Master, Release, Develop

Sometimes we need to fix a bug on release, and we need to report this fix on develop, to report our bug fix we use : git cherry-pick commit-SHA

With this command the bugfix is well reported on develop but the commit has a different hash

What we need :

Sometimes we need to know the list of commits that has not been reported, to do so, we use the command who compare the two branches and give us the list of commit which exist in release but not in develop : git log develop..origin/release

The ISSUE :

This command compare the hash of commits, but as i said before, when we report our commits, their hash changes, thus, we get some commits as if they were not been reported while they are

I'm lookin for a way to report our bugfix without changing the hash of commits, or a way to list the difference of commits between two branches, not by the hash but based on the message or another thing

Thanks

Tico
  • 2,686
  • 2
  • 30
  • 35
  • `cherry-pick` is not the right way to apply a commit to two branches. Read this [series of articles](https://blogs.msdn.microsoft.com/oldnewthing/20180323-01/?p=98325) to learn why `cherry-pick` is not good and how to do it correctly. – axiac Oct 06 '18 at 16:45
  • 3
    Commit hashes never change. Two things with different hashes are *different commits*. It sounds like you are looking for `git patch-id`, which computes a hash for the diff listing from `git show`, i.e., a hash ID for a changeset, as opposed to a hash ID for a commit. Two different commits will generate the same patch ID if they make the same changes to the same files, for some definition of "the same". – torek Oct 06 '18 at 17:41
  • 1
    Because this particular concept is fairly useful, Git has additional commands for working with patch IDs: `git cherry` does this for branch sets, and `git rev-list` has `--cherry-mark` for doing this with symmetric difference operations. All of them use the `git patch-id` code internally to do this, but if they don't do what you need, you can invoke `git show | git patch-id` to compute your own patch IDs and use them however you like. – torek Oct 06 '18 at 17:43
  • With all that said, see @axiac's link for a better way: one should only do this mucking-about with patch IDs if one is stuck in a horrible situation. – torek Oct 06 '18 at 17:45

1 Answers1

3
git log --cherry-pick develop...origin/release
  • The three dots between the branches ... means that you want to retrieve distinct commits from the two branches
  • From official documentation --cherry-pick option does :

"Omit any commit that introduces the same change as another commit on the “other side” when the set of commits are limited with symmetric difference."

Woody
  • 729
  • 7
  • 18