yanger
yanger

Reputation: 237

Can I bind 2 (or more) git commits and create dependency between them?

I have a git project. let's assume I am on side branch and I made a bug fix (Bug #XX) After delivery I discovered another another issue related to Bug #XX. Now I will have in git 2 commit referring bug #XX.

Let's say another developer also have a side branch and he want to cherry-pick my Bug #XX fix.

Is there a way to say git to bind this 2 commits as 1 commit. So when you cherry-pick one it will take both?

Of course I know I can cherry-pick them to a new branch and squash them to one commit. But I am assuming my side branch as master from which I deliver the product.

Is there a way to bind those two commits? And create a dependency between them?

Upvotes: 1

Views: 637

Answers (1)

sleske
sleske

Reputation: 83577

No, there is no feature to mark separate commits as "related" in git.

There are, however, several ways to handle this situation:

  • You can combine the two commits into one, as one does not make sense without the other. You can do that using cherry-picking + squashing, as you indicated, or using git rebase -i (note that this rewrites history, so the usual caveats apply).
  • If you have a rule that all development branches branch off master, and regularly merge in master to "synchronize" (a common workflow), you can cherry-pick/merge the bug fixes to master, and everyone will get them automatically.

The best solution, however, will depend on your git workflow (stable master + feature branches, unstable master + release branches, both, gitflow...). If you need a more specific answer, you will have to explain your workflow.

Upvotes: 1

Related Questions