Reputation: 83
I have the following situation:
A - B - C - ... DEVELOP
\
Z - X - ... FEATURE
I have created FEATURE branch to implement some feature in our project. And after I did some work there, I found a bug in the code, that should be fixed first. I can not finish the feature until the bug is fixed. That bug is not related only to the feature, so it should be fixed in DEVELOP branch.
The problem is, that DEVELOP and FEATURE branches are public.
I am confused and don't know to do. But there must be a clear solution for this?
Upvotes: 0
Views: 75
Reputation: 87503
Do you care if commits after FEATURE branched off of DEVELOP get into FEATURE from the hotfix?
You have options:
Originally
A - B - C - ... DEVELOP
\
Z - X - ... FEATURE
1. Isolated hotfix and merge to both: Only hotfix H, but not commit B nor C, gets incorporated into FEATURE.
A - B - C - D... DEVELOP
|\ /
| H ------ HOTFIX
\ \
Z - X - Y... FEATURE
2. Fix DEVELOP and then update FEATURE with changes up to hotfix via merge. This means commits B, C, and H get incorporated into FEATURE. This could be a problem for other devs using/basing off of FEATURE if you can't coordinate the change with them.
A - B - C - H... DEVELOP
\ \
Z - X ------Y... FEATURE
3. Fix DEVELOP and then rebase FEATURE to hotfix or later commit on DEVELOP - changes B, C, and H get incorporated into FEATURE. Only do this if you are comfortable with rebase and can coordinate a rebase safely with other devs. If, when you say that FEATURE is public, you mean wide-open, anyone-out-in-the-world-might-be-developing-off-of-FEATURE, then this isn't an option for you.
A - B - C - H... DEVELOP
\
Z - X -... FEATURE
Git will handle the merge of FEATURE back into DEVELOP fine in all cases. You still have to resolve any conflicts sooner or later, thats true regardless of the hotfix issue.
Upvotes: 1
Reputation: 19050
What you mean when you say that the branches are public? What is the problem?
Well, a solution in this case, if I understood correct, is open a new branch from develop:
git checkout -b hotfix develop
Do the correction in hotfix branch and merge the hotfix branch in both branches: feature and develop.
Upvotes: 2