I often create new branches locally (e.g., newLocalBranch), and then push them to the upstream remote origin, thus creating a new remote branch, using git push -u origin newLocalBranch. Is there a magit function equivalent to this operation?

1 Answer 1


magit-push-current-to-pushremote actually works perfect for me. If the branch already exists upstream, magit-push-current-to-pushremote will just push the committed changes upstream. If the branch does not yet have an upstream location set, magit-push-current-to-pushremote will prompt to select a remote location from the minibuffer (e.g., origin) to the branch to, defaulting to the same local name (i.e., newLocalBranch). Using magit-push, instead, would fail because no upstream location has been set for the newLocalBranch yet.

Per the documentation for magit-push-current-to-pushremote:

Push the current branch to ‘branch.<name>.pushRemote’. If that variable is unset, then push to ‘remote.pushDefault’.

When ‘magit-push-current-set-remote-if-missing’ is non-nil and the push-remote is not configured, then read the push-remote from the user, set it, and then push to it.

  • IIRC if you register the remote via magit it also offers to set the option and then the standard push does it too. Commented Mar 3, 2021 at 15:21
  • Please explain how that answers the question. Say what it does, for example.
    – Drew
    Commented Mar 3, 2021 at 15:49
  • If this is P p I don't see -u in the log, just -v.
    – Harald
    Commented Dec 5, 2022 at 12:38

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.