I understand that I can use 'git push -u [repo] [br]' to make [repo] 开发者_运维问答the default upstream for branch [br].
What I would like to do is set things up so that 'git fetch' fetches changes from one repo for a given branch, and 'git push' pushes changes to a different repo for that same branch.
So far reading the man pages and searching here hasn't turned anything up.
The reason I would like to do this is because there is an open source project (not hosted on GitHub), and I have created a fork of it (on GitHub), and would like to by default pull from the open source project, and by default push to my private fork.
See remote.<name>.pushurl
in git config. remote.<name>.url
sets your push and fetch location, but if you also specify remote.<name>.pushurl
, then the former is used only for fetches and the latter for pushes.
The git remote
command has a --push
flag when calling set-url
git remote set-url --push <name> <url>
For example:
git remote set-url --push origin git@github.com:username/repo/project.git
精彩评论