2

所以我有一个项目是一个 git repo,其中包含另一个 git 存储库。所以结构是这样的:

/gitProject
    /other
    /stuff
    /anotherGitProject

目前,我已经将另一个 GitProject 设置为 gitProject 的子模块。我的问题是我必须将 anotherGitProject 部署到硬盘的另一部分。由于 anotherGitProject 作为附加组件,我只需将 anotherGitProject 的内容直接复制到另一个项目的目录树中:

/gitProject
    /other
    /stuff
    /anotherGitProject
/otherProject
    /(contents of anotherGitProject+otherProject)

我的问题是:如何在 gitProject 中跟踪我对 anotherGitProject 所做的更改?这看起来真的很令人费解,但我需要在 otherProject 之上对 anotherGitProject 进行更改,否则这不会成为问题。

4

1 回答 1

2

这个想法是:

  • 克隆anotherGitProjectin otherProject
    甚至作为otherProject (如果anotherGitProject需要直接 在其中的内容otherProject,在这种情况下:
    • otherProject重 命名 otherProject.tmp
    • 克隆 anotherGitProjectotherProject
    • 将其余 otherProject.tmp内容 复制到otherProject
    • 添加 .gitignore 以忽略任何不是anotherGitProject原始内容的内容
  • 添加到anotherGitProject初始存储库(作为子模块的那个gitProject远程指向otherProject

这样,您可以otherProject直接取回/拉回anotherGitProject

如果 anotherGitProject是,作为一个插件,一个简单的子目录 otherProject,这个过程就简单得多,因为正如我在第一点中提到的,你可以简单地 anotherGitProject直接克隆到目标(在otherProject)中。
远程步骤是一样的:

cd /gitProject/anotherGitProject
git add remote anotherGitProjectDeployed /path/to/otherProject/anotherGitProject
于 2012-07-25T06:30:55.443 回答