0

There are 3 branches involved in this question. I have the master branch, I have a bug-fix branch, and I have a refactor branch.

This is the timeline:

  1. Created bug-fix branch off master to fix a bug.
  2. Created refactor branch off master to do some refactoring.
  3. bug-fix branch has been merged to master.
  4. Now in the refactor branch, I am going to refactor some areas in the file where the bug was fixed. But this branch still has the unfixed bug.

What's the best course of action to make at this point?

  1. Cherry-pick the fix from master into refactor branch?
  2. Continue refactoring and fix the conflict later on during merging.
  3. Rebase my current branch into master?
  4. Others?
catandmouse
  • 127
  • 2
  • 5

1 Answers1

4

Sync your branch by merging master into refactor. You'll have to deal with the merge conflicts eventually in any case, and by tackling them early you will decrease the complexity of the conflicts.

This is good practice in general: whenever your source branch changes, merge those changes into its dependent branches. You want to keep your branches ahead of their source. By avoiding the synch your branches wind up lagging further and further behind while punting smaller conflicts further into the future where they might be large and ambiguous. Better to address small conflicts with a greater frequency than large conflicts rarely.

JimJam
  • 339
  • 2
  • 9
  • By merging you mean rebasing unto master? – catandmouse May 06 '19 at 07:22
  • No, he means merging – RiaD May 06 '19 at 07:44
  • 3
    Rebasing would keep the history cleaner. So I prefer to rebase often instead of merging often. – pkempenaers May 06 '19 at 07:58
  • While I don't think there's anyhing wrong with rebasing instead of merging, I don't personally see what you would gain from rebasing before the branch is to be merged back into `master`. Still, if it suits your workflow better to rebase, go for it. I recommend not squashing any commits you have on the branch until you merge it back to `master`, though, since that history could be valuable during development. – JimJam May 06 '19 at 10:56