Ideally the relevant part of the popup looks like this:
Push feature to
p myfork/feature
u origin/master
e elsewhere
But in your case it probably looks like this:
Push feature to
e elsewhere
The p and u variants are missing because the relevant options are not set. p pushes to the configured push-remote, while u pushes to the configured upstream branch.
Edit: I have added another way of setting the upstream and push-remote. By default you would now see the following if both of them are unset:
Push feature to
p pushRemote, after setting that
u @{upstream}, after setting that
e elsewhere
See this question for more information.
The upstream branch, as suggested by the word "upstream", should be used for the "official" branch on the "official" remote. I.e. the branch on which most work is based and into which much changes should eventually be merged. Often this is "master" on "origin", i.e. "origin/master"; but it could also be something like "origin/maint" or "origin/next".
If you always work on just one branch "master" then the upstream branch and the branch you push to are the same, but if you use feature branches, then you don't want to push directly to "master".
A branch "feature" should usually be pushed to "feature" on "myfork", i.e. "myfork/feature". But because there might be more than one remote, e.g. "origin" and "myfork", you have to tell Git where you want to push to. This is done by setting the variable branch.pushDefault
:
git config branch.pushDefault myfork
You can also use b M-p to do the same. Keep pressing M-p until the remote which should be used as the push-remote is highlighted.
Often the push-remote should be the same for all branches, but when that is not the case, then you can override it for a single branch using e.g. branch.<feature>.pushRemote
. That variable too can be set from the branching popup.
The concept of a push-remote, which is destinct from the upstream, existed in Git for many years, but Magit did not support it until v2.4
. If you don't want to push-remote, because it "is an unnecessary complication", then you can just abuse the upstream as before.
But of course that too has to be configured. Usually the upstream is automatically set when you create a branch. But if that is not the case or if you need to change the value, then that to can be done from the branching popup, using b u (if you want to change the value then you have to press that twice, because the first time just unsets the old value).
You can also do that directly from the pushing popup using the --set-upstream
argument. In the popup first press - u to turn on that switch. Then you have to invoke a command which lets you choose where you want to push too. It seems fairly obvious that the correct command to do that is "Push feature to elsewhere". The word "elsewhere" is used here because usually a branch has an upstream and a push-to branch. If neither of the two is already configured, then the working might seem a bit strange, but it should still convey that you get to choose where that "elsewhere" is, i.e. to which branch you want to push. So press e.
The next time you come to the pushing popup it will look like this:
Push feature to
u myfork/feature
e elsewhere
But I recommend you instead make use of the distinction between the upstream and the push-remote and configure them as described above. One huge advantage of the push-remote is that you usually only have to configure it once per repository.
P u
?P -u e
. After you set your upstream this way, you should be able to useP u
to push in the way thatP P
worked in the past. Again, see the linked question and answers for details as to why this is the caseP -u e
is for. From themagit-status
buffer:P
: bring up the popup for push options;-u
: letmagit
know that you want to set the upstream branch;e
: for "elsewhere" to push push to a remote branch; So four keystrokes from the magit status buffer - at least this works in my case. Then once you hit return, you will be promted to select a branch to push to. Should save a few keystrokes compared togit push -u origin B