git pull和git push的不同默认远程(跟踪分支) [英] Different default remote (tracking branch) for git pull and git push
问题描述
有没有办法建立一个git仓库,这样 git pull
默认为一个远程,而 git push
默认为另一个?我知道我可以通过改变 .git / config 中分支部分的
远程
变量的值来设置 code>,但是如何为每个方向单独做?
对于Git 1.6.4和更高版本,设置 remote。< name> .pushurl
与 git config 。
这可以使用只读的 https:
协议并使用基于ssh的协议进行推送。
$ b $ < remote.origin.url
)为 https://git.example.com/some/repo.git
。它是只读的,但您可以通过基于ssh的'URL' git@git.example.com:some / repo.git
来写入权限。运行以下命令以推送基于ssh的协议:
git config remote.origin.pushurl git@git.example .com:some / repo.git
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?
For Git 1.6.4 and later, set remote.<name>.pushurl
with git config.
One might use this to pull using the read-only https:
protocol and push using an ssh-based protocol.
Say origin
's url (remote.origin.url
) is https://git.example.com/some/repo.git
. It is read-only, but you have write access through the ssh-based ‘URL’ git@git.example.com:some/repo.git
. Run the following command to effect pushing over the ssh-based protocol:
git config remote.origin.pushurl git@git.example.com:some/repo.git
这篇关于git pull和git push的不同默认远程(跟踪分支)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!