开发者

Is it possible to set git up to have default fetch/push locations that are different, and if so, how?

开发者 https://www.devze.com 2023-03-27 16:25 出处:网络
I understand that I can use \'git push -u [repo] [br]\' to make [repo] 开发者_运维问答the default upstream for branch [br].

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

0

精彩评论

暂无评论...
验证码 换一张
取 消