有没有办法设置git仓库,所以git pull默认为一个remote, git push默认为另一个? 我知道我可以通过更改.git/config分支部分中的remote变量的值来设置两者 ,但是如何分别对每个方向进行设置?
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?
最满意答案
对于Git 1.6.4及更高版本, remote.<name>.pushurl使用git config设置remote.<name>.pushurl 。
人们可能会使用这种方式使用只读https:协议来拉,并使用基于ssh的协议。
说origin的url( remote.origin.url )是https://git.example.com/some/repo.git 。 它是只读的,但您可以通过基于ssh的“URL” git@git.example.com:some/repo.git进行写入访问git@git.example.com:some/repo.git 。 运行以下命令来实现基于ssh的协议:
git config remote.origin.pushurl git@git.example.com:some/repo.gitFor 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更多推荐
发布评论