How to achieve `git --no-ff --ff-only` which is not allowed

前端 未结 3 1408
无人共我
无人共我 2020-12-24 07:49

As part our rebase-heavy workflow, I am hoping to use a merge on the master branch. In particular I want to merge only when the topic branch has been rebased onto the most r

3条回答
  •  余生分开走
    2020-12-24 08:07

    You don't want --ff-only because you do want to make a merge commit which --ff-only would inhibit.

    The check that you want can be made as a separate check before running the merge command. You could package this into a simple shell function.

    E.g.

    merge_if_ahead () {
      if test "$(git merge-base HEAD "$1")" = "$(git rev-parse HEAD)"; then
          git merge --no-ff "$1"
      else
          echo >&2 "Not up to date; refusing to merge"
          return 1
      fi
    }
    

提交回复
热议问题