一个项目,多个Git Repo合并问题

时间:2017-11-01 22:32:57

标签: git github gitlab

我正在开发一个希望拥有以下工作流程的项目:

开发团队从内部Gitlab仓库执行正常的git工作流程,让我们称这个仓库为“Alpha”在某些时候,我们对项目的状态感到满意,做了内部审查并希望将新代码推送到Github (repo“Beta”)。

听起来很简单,除了我们都是相当新的git,并尝试了几种不成功的方法。令人沮丧的是,我们克隆Beta,除了文件形式repo Alpha中的.git dir副本之外的所有文件(再次除了.git dir),做一个提交-a,推送,声明成功,然后走一个感觉不得不有更好的方式。

所以这是我们使用“git”做最新努力的“日志”:

Repo Alpha =内部git实验室 Repo Beta =外部github项目

~ $ mkdir work
~ $ cd work
~ $ # create the clone of Beta
~ $ git clone https://github.com/foo/xot.git
~ $ # create the clone of Alpha
~ $ git clone git@internal.foo.com:xot/XOT.git
~ $ ls
xot/       XOT/
~ $ # go work in the clone of Beta
~ $ cd xot
~/xot $ git status
On branch master
Your branch is up-to-date with 'origin/master'.
~/xot $ git remote add Internal ../XOT
~/xot $ git remote -v
Internal    ../XOT (fetch)
Internal    ../XOT (push)
origin    https://github.com/foo/xot.git (fetch)
origin    https://github.com/foo/xot.git (push)
~/xot $ git pull Internal master

<boom>
1000's of conflicts

当然,我们可以做“git mergetool”和老年人死亡,正如我们所说,“是的,删除那个文件”,“是的,把内部回购的版本”带到成千上万的冲突中。

以下是我们要做的事情的图表表示:

               commits
Repo Alpha     a12f -----> c676 -----> .... ----> d4a2

now we want to apply all the commits to repo Beta:

Repo Beta      a12f ----------------------------> d4a2

关于我看到引用(https://git-scm.com/docs/git-merge/2.14.2)到“git pull -s theirs”作为可能的automerge策略。除了git错误说他们的不是一个有效的策略(我在Ubuntu 14.04上运行git 2.14.2)

我们在这里缺少什么?是否有适当/更好的方法来做到这一点?

1 个答案:

答案 0 :(得分:0)

您需要做的是创建repo Alpha。然后任何想要进行更改的人都需要分配回购。当他们想要合并他们的更改时,他们只需要从他们的fork(beta repo)做一个alpha请求。

https://help.github.com/articles/fork-a-repo/

https://help.github.com/articles/about-pull-requests/