1

it was the work flow,

  1. Created my branch using checkout.
  2. Commit my changes on my branch 5 days ago.
  3. Edit some of it on same branch and commit (not merged, on review). Found that there is version set issue because someone merged changes on main branch 3 days ago.
  4. I need to keep working on same branch and need to commit. (Should be merged to main when review is approved) Before keep working on what should I do? should I do git pull origin mainline —rebase? on my branch? Cherry pick?
Devep
  • 23
  • 4
  • You should keep working on the branch in the state it is currently in. IMO, it is bad practice to pull in (merge or rebase onto) other work at random times; do that only (1) after you finished your work, or (2) you absolutely need the changes that the other work introduced. Note that *there is no (3)* when your work will be in conflict with the other work. – j6t Nov 15 '22 at 06:37

1 Answers1

1

Whenever you know you will have to merge your branch to an integration branch, like the main branch, it is best practice to rebase first your branch (especially if you are the only one working on it) on top of the target branch (main).

That way, you replay your changes on top of any up-to-date content, and can resolve locally any conflicts, making sure your additional commits take into account main recent commits.

Then you create your PR. Or force push your branch to update your existing PR: the review can resume with your new pushed content.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250