Is there a way to set up a git repository, so that git pull
defaults to one remote and git push
defaults to another? I know I can set both by changing the value of the remote
variable in branch section of .git/config
, but how to do it for each direction separately?
views:
41answers:
2
+1
A:
From what I can gather from the git config man page, the upstream repo is:
- by default origin
- set by
branch.remote
- always for both
git pull/fetch
andgit pull
For a given branch, I don't see any way to have two separate remote by default.
VonC
2010-05-26 21:27:08
+3
A:
For Git 1.6.4 and later, set remote.<name>.pushurl
with git config.
One might use this to pull using the read-only git:
protocol and push using an ssh-based protocol.
Say origin
's url (remote.origin.url
) is git://git.example.com/some/repo.git
. It is read-only, but you have write access through the ssh-based ‘URL’ [email protected]:some/repo.git
. Run the following command to effect pushing over the ssh-based protocol:
git config remote.origin.pushurl [email protected]:some/repo.git
Chris Johnsen
2010-05-26 21:37:47