1

which one is the best way?

On develop branch:

1)

  • git checkout -b feature
  • git add .
  • git commit -m "done"
  • git checkout develop
  • git pull origin develop
  • git merge --no-ff feature
  • resolve conflicts
  • git push origin develop
  • code review

2)

  • git checkout -b feature
  • git add .
  • git commit -m "done"
  • git push origin feature
  • code review
  • resolve conflicts
  • git merge > to develop
Theory_Theory
  • 51
  • 1
  • 3
  • We currently rebase with main until we merge into main. Making the flow `git checkout -b new`, work work... `git rebase --onto origin/main $(git log --merges -1 --format=%h)`, ... and then finally merge it into main with a merge commit. – Andreas Louv Jun 09 '22 at 08:33

1 Answers1

1

A code review is not supposed to take place on the target branch (in your case "develop"), only on the source branch, rebased first on top of the target branch.

The idea of a code review is to allow the final merge only if the CR passes.
If the review rejects the commit, no merge.

So:

git fetch
git switch feature
git rebase origin/develop
# resolve conflicts, test everything
git push --force-if-includes 
# request a review before merge, through for instance a pull request

(On --force-if-includes, see this answer)

If you are several to work on feature branch, do communicate when you rebase the branch, as it will change its history, and your colleagues will have to reset their local feature branch to the new origin/feature forced pushed one.

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