Different default remote (tracking branch) for git pull and git push

前端 未结 5 1949
情深已故
情深已故 2020-11-30 22:59

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

5条回答
  •  萌比男神i
    2020-11-30 23:20

    For Git 1.6.4 and later, set remote..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
    

提交回复
热议问题