github - Why does the the same conflict reappear when I use git rebase? -


i have read relevant questions git merge , git rebase on so, still cannot understand happening under hood.

here our branching situation:

master------------------------         \        \          \        \----feature b---           \                        \            \-----feature a----------\---feature a+b 

we have 2 feature branches stem master @ different time, want combine 2 branches. want follow first rebase merge practice, when rebase feature feature b, conflicts. that's expected, because both features (and master) have changes in same areas. strange thing same conflict keep reappearing after git rebase --continue. drives crazy, end aborting rebase, , use git merge. turns out conflicts easy resolve.

my question two-fold:

  1. is git rebase suitable our situtation? or rebase pulling in few (1 or 2) changes?
  2. what happening under hood causes same conflict reappear again , again? understanding rebase resolve conflicts 1 @ time, comparing commit what?

relavant posts on so:

is rebase suitable situation?

based on fact feature a , feature b seem shared branches, i'd no.

rebasing way merge branches without having merge commits (i.e. commits have 2 or more parents) making appear linear history. it's best used merge local branches, branches exist in local repository , haven't been published other people. why? because of @ least 2 reasons:

  1. rebasing changes commit ids (i.e. sha-1 hashes of metadata). means once push rebased commits shared branch, appear new commits fetches them on local repo, if still contain same changes. now, if has added new commits on top of old ones in meantime, have move them. creates unnecessary confusion.

  2. when merge public branches want have merge commits in order able track how commits moved across branches. information lost rebasing.

what's happening under hood?

just regular merge. difference git rebase merges one commit @ time on top of previous 1 starting common parent. git merge merges 2 commits – entire set of changes – single operation, have resolve conflicts once.

update: resolving recurring conflicts

as @jubobs pointed out in comments, git have automated solution resolving conflicts occur multiple times: git rerere, or "reuse recorded resolution".

after enable rerere in configuration file (rerere.enabled true) every time merge conflict occurs, git record state of conflicting files before , after merge them. next time same conflict occurs – conflict involving exact same lines on both sides of merge – git automatically apply same resolution had recorded previously. let know in merge output:

conflict (content): merge conflict in 'somefile'
resolved 'somefile' using previous resolution.

here can find more details on how deal conflicts using git rerere.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -