When I want to push to a different upstream than origin, I use P C-u C-u P so I can set the upstream of the command, however magit always prompts me with question to set upstream also. How do I prevent that prompt?
2 Answers
Beginning with v2.1
Magit features several push variants, all of which are available from the new pushing popup on P. In v2.4
this has been improved again. The popup now features p to push to the configured push-remote, u to push to the configured upstream branch, and e to push to somewhere else.
By default p and u offer to set the respective remote/branch before pushing if it is not configured yet.
Also there is a new magit-branch-set-upstream
command, which b u is bound to. And when creating a new branch with a starting-point that is a remote branch, then that is automatically used as upstream. After running git commit --global branch.autoSetupMerge always
once, the same happens if the starting-point is a local branch.
Also see this answer on a related question.
And to learn more about the push-remote see the Branching node in the info manual, as well as this answer.
This wouldn't fit in the comment. Make sure you have in your .git/config
file something like:
[push]
default = tracking
[remote "github"]
url = https://github.com/path-to-repostiry.git
fetch = +refs/heads/*:refs/remotes/github/*
[branch "master"]
remote = github
merge = refs/heads/master
In particular that you have the [branch "branch-name"]
. Without this part Magit will always ask for the branch to push to, no matter what your push policy is or what other Magit settings you use (not sure why though).
You will also see that in the Magit status buffer, in the description part you will see the Local:
line.
magit-set-upstream-on-push
. Will a single prefix do what you want? (This way you specify the remote but keep the branch name the same as the local branch.)