提交更改到镜像仓库

3
为了开始一个新的nopCommerce项目,我创建了一个私有的git仓库。我想要能够拉取源代码的最新更改,所以我复制了官方的nopCommerce repo (https://help.github.com/articles/duplicating-a-repository/)。我希望能够提交一个更改到我的私有仓库,将自定义主题添加到项目中。为了能够轻松地拉取和合并来自官方repo的更改,我应该在哪里提交更改?此外,镜像仓库中的操作应该如何影响我的git工作流程?在我最近的项目中,我使用了gitflow (https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)。
1个回答

2
如果您已经将原始的“上游”存储库复制到自己的私有Git存储库中,这意味着您在工作站上的本地克隆副本现在应该推送到您的私有存储库。
这是由于git remote set-url --push origin https://github.com/exampleuser/mirrored命令(来自GitHub教程)的作用。
它允许您从原始存储库拉取并推送到您的镜像。
然而,如果您打算添加自己的提交,则此私有存储库应该是一个分叉,而不是一个镜像。
这意味着:
  • referencing the original repo as "upstream" (instead of the fetch url of the remote origin)

    git remote add upstream $(git remote get-url origin)
    
  • setting both push and fetch url of origin to your private repo

    git remote set-url origin $(git remote get-url origin)
    
之后,您可以应用任何工作流程(例如 git-flow)到您的私有 repo 上,同时仍然能够从 upstream 拉取并合并(或在其之上进行变基)原始 repo 中的任何新提交,现在该 repo 被引用为 upstream

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接