this should be a relatively trivial problem, I just (very) new to using Git, so please forgive the simple question. I need to get some updates along our Development branch into a Feature branch because they are critical, however there's a minor complication in that some of the updates on Feature were pushed previously, but not all of them.
I've been reading git manuals, I've had a look around and I'm not 110% I have this entirely down yet. I'm not certain how this works...
A ---- B ---- C ---- D ---- E ---- F ---- G ---- H [DEVELOPMENT]
\ /
\ /
I ---- J ---- K ---- L ---- M [FEATURE]
Therefore, our current state:
My IDE reports my Feature branch is 2 Ahead {L,M}, and 4 Behind {E,F,G,H}.
We need the most recent updates committed to Development to be drawn into Feature, so I can keep going. It should look something like:
A ---- B ---- C ---- D ---- E ---- F ---- G ---- H [DEVELOPMENT]
\ / \
\ / \
I ---- J ---- K ----- ------ ------ ----- L ---- M [FEATURE]
How do I fix this solution, without making the remote branch system in particular ugly or fragmented? This should be a very simple rebase or merge operation from the Feature branch, one command, right?
git rebase Development (then correct any conflicts)?
I don't know what this will do to the remote, and I really don't want to break anything for anyone. If anyone could enlighten me on how to do this properly, I'd appreciate it. :)
You will alway want to keep your feature branch up to date in respect to the development branch.
This can be done either by pull or by rebase. Since you already pushed, rebase would create new potential problems.
So simply do:
git merge development
from your feature branch. The result is that all your critical commits are now part of the feature branch, exactly as you want it.
First you have to fix your local branch:
git checkout M
Bring your local feature branch up to date with either
git rebase H or
git merge H (I prefer rebase)
At this point, you may have to fix some conflicts with git mergetool, just follow the instructions.
Now you can update the remote feature branch from your local feature branch:
git push origin feature_branch:feature_branch
You only have to worry about remote branches when you push, everything else is done locally. On the last command for example, the only affected remote branch is the one after the : , in that case feature_branch.
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