所以我有一个 git 存储库项目,其中包含另一个 git 存储库。所以结构是这样的:
/gitProject
/other
/stuff
/anotherGitProject
目前,我已经将 anotherGitProject 设置为 gitProject 的子模块。我的问题是我必须将 anotherGitProject 部署到硬盘的另一部分。由于 anotherGitProject 作为一个附加组件,我只需将 anotherGitProject 的内容直接复制到其他项目的目录树中:
/gitProject
/other
/stuff
/anotherGitProject
/otherProject
/(contents of anotherGitProject+otherProject)
我的问题是:如何跟踪我在 gitProject 中对 anotherGitProject 所做的更改?这看起来确实很复杂,但我需要在 otherProject 之上对 anotherGitProject 进行更改,否则这不会成为问题。
最佳答案
这个想法是:
- 在
otherProject
中克隆anotherGitProject
,
甚至作为 otherProject(如果anotherGitProject
的内容需要直接位于otherProject
中,在这种情况下:- 重命名
otherProject.tmp
中的otherProject
- 克隆
anotherGitProject
为otherProject
- 将
otherProject.tmp
的其余内容复制到otherProject
- 添加 .gitignore 以忽略任何不是
anotherGitProject
原始内容的内容
- 重命名
- 添加到
anotherGitProject
初始存储库(该存储库是gitProject
的子模块) remote指向otherProject
这样,您就可以直接从 otherProject
获取/pull 回 anotherGitProject
如果 anotherGitProject
作为插件,是 otherProject
的一个简单子(monad)目录,则过程要简单得多,因为,正如我在第一点中提到的,您可以简单地直接在目标位置(在 otherProject
内)克隆 anotherGitProject
。
远程步骤相同:
cd /gitProject/anotherGitProject
git add remote anotherGitProjectDeployed /path/to/otherProject/anotherGitProject
关于windows - 如何跟踪不同目录中的 git 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11640195/