2012-07-24 50 views
2

所以我有一个项目,它是一个包含另一个git仓库的git仓库。所以结构是这样的:如何跟踪不同目录中的git存储库?

/gitProject 
    /other 
    /stuff 
    /anotherGitProject 

目前,我有另一个gitproject设置为gitProject的子模块。我的问题是我必须将另一个GitProject部署到我的硬盘的另一部分。由于anotherGitProject功能作为一个附加的,我只是anotherGitProject的内容直接复制到其他项目的目录树:

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

我的问题是:我怎么可以跟踪的变化我做出anotherGitProject内gitProject?这看起来真的很复杂,但我需要对其他项目顶部的另一个GitProject进行更改,否则这不会成为问题。

回答

2

的想法是:

  • 克隆anotherGitProjectotherProject
    甚至 otherProject(如果anotherGitProject需要的内容直接地是内otherProject,在这种情况下:
    • 重命名为otherProjectotherProject.tmp
    • 克隆anotherGitProject as otherProject
    • 复制的内容otherProject.tmpotherProject
    • 其余添加的.gitignore忽略任何这是不anotherGitProject原始内容
  • 添加到anotherGitProject初始回购(的一个是子模块gitProject)一remote指向otherProject

这样的话,你可以获取/从otherProject直接巴拉CK在anotherGitProject

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

cd /gitProject/anotherGitProject 
git add remote anotherGitProjectDeployed /path/to/otherProject/anotherGitProject 
+0

感谢您的帮助。对我来说关键是为​​另一个GitProject创建一个远程。由于我没有拥有它,我不得不在github上创建自己的版本,然后将它用作gitProject中的子模块。 – Ridwan 2012-07-28 05:45:28

相关问题