gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 13:17:06 33 4
gpt4 key购买 nike

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

origin git@github.com:user1/repo.git (fetch)
origin git@github.com:user1/repo.git (push)

如果我对位于 http://github.com/user2/user2srepo 的其他人的存储库(假设 user2)具有获取和推送权限,我会怎么做。 git?

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

最佳答案

假设您的 github 存储库都用于相同的代码库,您可以将它们都作为远程添加到您的本地存储库:

git remote add otherusersorigin http://github.com/user2/user2srepo.git

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

git fetch otherusersorigin
git push otherusersorigin

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

关于git - 设置 git 推送到另一个用户的 Github 仓库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11526634/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com