2

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
  • 1
    It seems that a double C-u both asks for the name of a branch and will always ask to set the upstream, regardless of the value of 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.)
    – Kyle Meyer
    Mar 19, 2015 at 21:29
  • Thanks, that's what I get for cargo culting the C-u C-u.
    – PuercoPop
    Mar 20, 2015 at 3:38

2 Answers 2

4

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.

1

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.

1
  • It is not the branch I change, but the remote
    – PuercoPop
    Mar 20, 2015 at 3:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.