【问题标题】:How to share git branches that are based on same repository?如何共享基于同一存储库的 git 分支?
【发布时间】:2013-07-19 12:54:44
【问题描述】:

我是一名新手程序员,对 GitHub 完全陌生。我正在与一位同事合作开展他多年来一直从事的项目。

到目前为止:

他创建了一个存储库并加载了所有初始文件。我将它分叉到我的帐户中,以便我可以单独处理它。

现在:

我如何提交我的存储库并与他共享,以便他可以检查更改并将其合并到他的存储库中,如果他喜欢这些更改?

我知道 GitHub 上有很多信息,但我什至不知道从哪里开始。非常感谢任何帮助。

【问题讨论】:

  • 我分叉到我自己的帐户会更好。 branched 是一个完全不同的概念。

标签: php git version-control collaboration


【解决方案1】:

在您的情况下推荐的方法是与您的朋友合作。

方法如下:

Add a collaborator

Read this: 将为您介绍 git 的基础知识以及如何与他人协作。

【讨论】:

    【解决方案2】:

    有很多方法可以做到这一点,github 推荐拉取请求,除非您没有对存储库的推送访问权限,否则您将需要这样做或发送补丁。有这样一个工作流的例子here

    git clone git@github.com:<their repo> [optional folder name]
    cd reponame (or optional folder name)
    

    如果仓库有子模块,那么

    git submodule update --init (if the repo has submodules)
    git submodule foreach 'git checkout <their working branch>'
    

    分叉代码。分叉您计划处理的特定存储库。这将为您提供您自己的项目副本。在您计划处理的存储库中设置 git。

    cd <repo dir or optional one chosen)
    git remote set-url origin git@github.com:<your github name>/<your repo>.git
    git remote add --track next upstream git://github.com/<their github name>/<their repo>.git
    

    这是为帮助编写代码而设置的存储库。您可以执行 git pull、git push 等(这将来自/来自您的 fork)。要从合作伙伴 repo 的分支中提取更改,只需执行以下操作:

    git pull upstream branch
    

    您将无法 git push 到他们的仓库,因为您需要执行拉取请求。

    当您满意时,请转到 github(您的项目)并选择 diff 和 pull request。这允许您输入一条消息,lib 维护者将收到一条消息来处理请求。它还会显示您的拉取请求是否会干净地合并,如果维护者必须修复代码,则不太可能被接受。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-16
      • 2011-03-21
      • 2019-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多