Suppose I am part of a development team and we all work on different branches from a same project:
o--o--o--o (Bob)
/
o--o---o---o---o---o--o (Me, master)
\
o--o--o---o (Alice)
Today, I discover a bug in a common file to Alice and Bob. This is an old bug.
How do I fix it in the other branches? What is the workflow in this situation?
I suppose the correct way to proceed is to generate a patch that I personally email to Alice and Bob: "Hi, Alice and Bob, I found a bug that appeared on commit 7a6b87f. Please find the patch attached to this email".
The solution seems to be very simple if there is only three people working on the project. How do I manage it on a bigger project with more branches and more developers?
Of course if I am alone on the project I can simply use this solution.
You could do what David, states, but instead of merging, you can use cherry-pick
command.
Another option using cherry-pick
is to just cherry-pick the changes that you had made on your branch to the other branches.
Before doing that this way you have to be sure that the changes on the commit belong to and only to the bug fix.
Then you simply go to each of the other branches and git cherry-pick <commit hash>
if there any conflicts you will have to resolve it.
That's the right way to do it, I think, I'm doing that way and seems more git-way.
Here the docs: http://git-scm.com/docs/git-cherry-pick
I would create a branch off of the common ancestor of Alice and Bob, fix the bug there, and then merge that branch into Alice, Bob, and master. This way you only fix the bug once, in a single commit.
you can easly bash script your way out of this with
for branch in branch1 branch2 branch3; do git checkout $branch && git cherry-pick a970d6ecd; done;
I like the common ancestor solution too then :
for branch in branch1 branch2 branch3; do git checkout $branch && git merge common-ancestor-branch; done;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With