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?
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
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.