In magit
, you can use the C-u
prefix argument to allow you to set the remote for push and pull operations. You would type C-u F -r F upstream<RET>
to do this. If you need to also specify the branch name, you can double the C-u
prefix: C-u C-u F -r F upstream<RET> master<RET>
. In the next version of Magit, 2.1.0, this will be available in the more accessible F -r o
rather than having to use the prefix argument.
If that's too cumbersome, I suggest setting the upstream explicitly in your .git/config
; then all pulls will come from that upstream. You can do this with git branch -u upstream/master
while on your local branch, or git branch -u upstream/master mybranch
if you're on a different branch. Then, whether you use Magit or git
on the command line, a simple git pull --rebase
or F -r F
will pull from the configured branch.
If you need to push to your own personal repo while pulling from a different repo, you can always set up a separate remotes for pushes and pulls. There is no convenient command wrapper for this that I know of, but if you edit your .git/config
directly, you would do so as follows:
[branch "mybranch"]
remote = upstream
pushremote = origin
merge = refs/heads/master
If you're doing this, and will always be rebasing your local branch, you could even add:
rebase = true
And not have to specify --rebase
ever time you pull.
If you want to do this for your whole repo, instead of a single branch, you can use:
[remote]
pushdefault = origin
And then have the branches pull from their configured upstream, but push to your own repo.