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

前端 未结 5 1956
情深已故
情深已故 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条回答
  •  心在旅途
    2020-11-30 23:16

    user392887's answer is mostly correct, but:

    1. You should prefer to use SSH. According to GitHub, "We strongly recommend using an SSH connection when interacting with GitHub. SSH keys are a way to identify trusted computers, without involving passwords."

    2. Anyone using RHEL/CentOS 6 will be using git 1.7.1 by default, which supports set-url.

    So, the preferred solution for git 1.7.1. and later is:

    git remote set-url --push origin git@github.com:username/somerepo.git
    

提交回复
热议问题