设置git推送到另一个用户的Github仓库?

Nic*_*ick 5 git github

假设我user1和我有一个Github帐户http://github.com/user1.当然,我会在本地设置git:

origin git@github.com:user1/repo.git (fetch)
origin git@github.com:user1/repo.git (push)
Run Code Online (Sandbox Code Playgroud)

如果我获取并推送其他人的回购(让我们说user2)回购所在的回购权限,我该怎么办http://github.com/user2/user2srepo.git

编辑:对不起,每个人都对他们的答案是正确的.我应该澄清一下,我曾经把它设置为origin http://github.com/user2/user2srepo.git但我想避免每次推送都被要求提供用户凭据.

Mat*_*son 8

假设你的github repos都是相同的代码库,你可以将它们作为遥控器添加到你的本地仓库:

git remote add otherusersorigin http://github.com/user2/user2srepo.git
Run Code Online (Sandbox Code Playgroud)

然后在需要时使用该别名:

git fetch otherusersorigin
git push otherusersorigin
Run Code Online (Sandbox Code Playgroud)

要在没有身份验证提示的情况下执行此操作,请根据标准GitHub说明为您自己设置SSH密钥,并让其他人将您添加为该repo上的协作者.