version control - Git fails at rebasing in modified commits -
we use gerrit code reviewing. when working larger issue, send several commits gerrit depend on each other. here 1 such situation, a, b , c commits awaiting code review in gerrit:
c | b | | origin/master
if comment on a, need fix whatever issue code reviewer found, , make new commits a, b , c (gerrit never able handle conflicts arise when dependency b changes). fix this, check out new branch called cr_fix i'm working (let's master), , git reset --hard head^^ (or using id commit a) end this:
a | origin/master
i can fix reported issues in a, make new commit , push gerrit. go master , do
git rebase cr_fix
the intention replace commit in master commit in cr_fix.
this strategy works me, plagued git registering merge conflicts - doesn't seem able solve simplest things.
most notably first commit handles in final rebase command (a in cr_fix on top of in master) conflicts practically everywhere change made in cr_fix.
i've learned can start rebase off git rebase --skip, i'm nervous i'll , lose commit somewhere.
so there way can modify workflow won't have deal these constant conflicts when rebasing? maybe option can use or set?
your problems stem trying rebase on top of a' (using capital letters here readability). want rebase b , c on top of a', creating b' , c'. easiest way of doing use interactive rebase,
git rebase -i origin/master
and amend a', , git automatically put b , c on top. can of course still cause conflicts, if a' touches exact same code b or c that's inevitable.
if insist on creating new branch fixing a' that's fine (although think you're working unnecessarily hard) have make sure you're not trying apply a.
when run
git rebase cr_fix
you're saying "backtrace current branch until find commit that's reachable cr_fix , rebase commits cr_fix". given situation you're in,
o----a----b----c ^ \ | ------------a' | ^ origin/master | cr_fix
you'll rebasing a, b, , c on top of a'. make sure you're rebasing b , c, use git rebase --onto
:
git rebase --onto a'
this means "backtrack until commit reachable , rebase commits onto a'".
Comments
Post a Comment