【问题标题】:Pushing to another user's remote repository without the use of pull requests在不使用拉取请求的情况下推送到另一个用户的远程存储库
【发布时间】:2016-03-19 20:35:07
【问题描述】:

我正在尝试创建一个 github 存储库,一组 4 位用户可以同时在该存储库上工作,而不必为每次推送提出拉取请求或在每次进行更改时进行分叉。

但是,当不是创建者(我)的任何人添加远程 URL 并尝试推送到主分支时,它会拒绝用户访问,即使用户作为贡献者添加到 github 页面上也是如此。

为了解决这个问题,我告诉其中一位用户 fork 存储库并将我添加为贡献者,以便我可以尝试推送新的更改,但我遇到了同样的问题。

我在 Git Bash 中做了以下操作:

$ git clone https://github.com/Diseasedfire/AlaBonteKoe.git
Cloning into 'AlaBonteKoe'...
remote: Counting objects: 3027, done.
remote: Compressing objects: 100% (66/66), done.
remote: Total 3027 (delta 27), reused 0 (delta 0), pack-reused 2955
Receiving objects: 100% (3027/3027), 37.23 MiB | 588.00 KiB/s, done.
Resolving deltas: 100% (494/494), done.
Checking connectivity... done.

$ vim README.MD

(I make edits to the readme)

$ git commit -a -m "test remote commit"
[master 318b667] test remote commit
 1 file changed, 1 insertion(+)

$ git remote add origin https://github.com/nebbii/AlaBonteKoe.git
fatal: remote origin already exists.

$ git remote -v
origin  https://github.com/Diseasedfire/AlaBonteKoe.git (fetch)
origin  https://github.com/Diseasedfire/AlaBonteKoe.git (push)

$ git push origin master
remote: Permission to Diseasedfire/AlaBonteKoe.git denied to nebbii.
fatal: unable to access 'https://github.com/Diseasedfire/AlaBonteKoe.git/':
The requested URL returned error: 403

是否可以作为列出的贡献者将更改推送到存储库而无需创建拉取请求?

【问题讨论】:

    标签: git github git-bash git-remote


    【解决方案1】:

    绝对有可能!

    我建议使用 SSH 协议来克隆存储库。这样您就可以使用 ssh 密钥进行身份验证,而不是 http 基本身份验证。

    $ git clone git@github.com:Diseasedfire/AlaBonteKoe.git
    

    也可以在 Github 上查看 documentation

    【讨论】:

    • 奇怪,当我尝试通过 SSH 密钥克隆存储库时,我得到以下信息:权限被拒绝(公钥)。致命:无法从远程存储库中读取。请确保您具有正确的访问权限并且存储库存在。
    • 你确定在你的 Github 设置中使用的是与公共密钥对应的私有 ssh 密钥吗?
    【解决方案2】:
    $ git remote add origin github.com/nebbii/AlaBonteKoe.git
    fatal: remote origin already exists.
    
    $ git remote -v
    origin  github.com/Diseasedfire/AlaBonteKoe.git (fetch)
    origin  github.com/Diseasedfire/AlaBonteKoe.git (push)
    

    当您查看 git remote -v 的输出时,您可以看到已经有一个名为 origin 的远程。因此,如果要添加新的远程 URL,则需要将远程命名为不同的。

    git remote add FOO github.com/nebbii/AlaBonteKoe.git
    

    然后你可以推送到另一个仓库。 (git push FOO master) 用于将分支 master 推送到 FOO

    但是要回答您的主要问题。 只需创建一个 github 存储库,将其他人添加为贡献者,然后让他们克隆您的存储库。然后你们 4 中的一个可以创建自己的分支并在该分支上工作。稍后,如果您需要其他人的代码/东西,只需将其合并到 master 或您需要代码的分支中。

    供进一步阅读;如果分支未共享,您也可以使用 rebase 或只看这里: https://github.com/nvie/gitflow

    【讨论】:

      猜你喜欢
      • 2015-05-16
      • 2019-03-05
      • 2022-11-02
      • 2019-09-27
      • 2019-09-18
      • 1970-01-01
      • 2017-07-22
      • 2019-06-02
      • 2013-12-05
      相关资源
      最近更新 更多