合并来自多个GIT仓库的变更?

时间:2011-02-03 01:22:48

标签: git

除了GIT的基本功能外,我几乎都是新手。这是场景。

我有多个GIT回购:

  • Torque3D.git
  • MyGame.git

Torque3D.git包含Torque3D的来源。 Garage Games以源转储的形式提供更新(无CSM访问)。随着Garage Games提供更新,Torque3D.git会随着这些更改而更新。

MyGame.git最初是从Torque3D.git克隆的,并在适当时从Torque3D.git中提取这些更改。在这种情况下,我总是从Torque3D.git中提取所有更改。这很好。

然而,当我们在MyGame.git中对引擎进行更改时,我们有时想要将特定更改推回到Torque3D.git,但不是所有对MyGame.git所做的更改。

我们如何才能允许这种访问?

2 个答案:

答案 0 :(得分:1)

创建一个单独的分支,仅包含要推回Torque3D的更改,然后从该分支拉入Torque3D仓库。

答案 1 :(得分:1)

正如Amber所说,你可能想要对这些变化做一个单独的分支。以下是我将通过带有MyGame分支的git仓库以及用于跟踪T3D仓库的Torque3D分支来做的事情:

# should already have: git remote add t3d git://any/url/or/path/to/your/Torque3D.git
# should already have: git remote add origin git://any/url/or/path/to/your/MyGame.git
git checkout -b patchedT3D t3d/master
# use git log origin/master and find hashes of changes you want.  For each:
git cherry-pick c3df34262 # do this to add a rev's changes to Torque3d
# manually patch in whatever you want and commit if you have to
git push t3d +patchedT3D
# or push to whichever branch you want to have your changes with patchedT3D:<whatever>
git checkout -b withPatched origin/master
git merge --strategy=ours patchedT3D -m "mark your MyGame trunk as using the patched T3D changes so they don't get re-merged in later"
git push origin withPatched:master

这应该为您概述一个可能的过程。