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
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
magitit also offers to set the option and then the standard push does it too.Dirk Eddelbuettel– Dirk Eddelbuettel2021-03-03 15:21:56 +00:00Commented Mar 3, 2021 at 15:21 - Please explain how that answers the question. Say what it does, for example.Drew– Drew2021-03-03 15:49:51 +00:00Commented Mar 3, 2021 at 15:49
- If this is
P pI don't see-uin the log, just-v.Harald– Harald2022-12-05 12:38:47 +00:00Commented Dec 5, 2022 at 12:38