0

I have upstream set to the develop branch (say origin/master) and pushRemote to a feature branch.

I currently use pulling with preserving rebase.

I would like to setup magit in such a way that:

  • this would be used by default for feature branch (pushRemote)
  • but pulling from develop branch should be done with merge (upstream).

Is it possible to reconfigure magit for that behavior? Probably this could be configured in git itself?

EDIT:

I came up with a safe-guard to prevent me from accidentally rewriting history by applying the following advice:

(defun my-magit-pull-from-upstream (org-fun &rest args)
  (if (yes-or-no-p "Do you really want to pull (rebase) from upstream? ")
      (apply org-fun args)
    (when (yes-or-no-p "Do you want to merge from upstream? ")
      (setq args '("--no-rebase"))
      (apply org-fun args))))

(advice-add 'magit-pull-from-upstream :around #'my-magit-pull-from-upstream)

1 Answer 1

1

Is it possible to reconfigure magit for that behavior? Probably this could be configured in git itself?

No and no. But you already found a workaround (which you should probably post as an answer).

I would like to setup magit in such a way that: [...] pulling from [the upstream branch] should be done with merge

You shouldn't do that. When you merge a branch into another branch using a merge commit, then the "branch on the right", i.e. the second parent of the merge commit should always be the "lesser" branch that is being merged into the other branch.

What you want to do creates commits whose message is Merge remote-tracking branch 'origin/master' into some-feature. Such a merge suggests that the "short-lived branch origin/master" is being merged into the "long-lived branch some-feature", which obviously isn't correct. This does not only confuse humans but also tools like git blame.

I recommend you simply rebase in this case too. In fact I would argue that it is more important that you do it in this case than in the case in which you already want to use rebase.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.