windows - 如何跟踪不同目录中的 git 存储库?

标签 windows git git-submodules

所以我有一个 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
    • 克隆anotherGitProjectotherProject
    • 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/

相关文章:

windows - Git Bash - 段错误问题(Windows)

c++ - 编写自定义 GetModuleHandle 函数的原因是什么?

php - 在 MicroApache 中运行 SQLite 3

c++ - 仅当程序处于焦点时退出循环的关键监听器(c++)

git - 克隆一个包含所有子模块的 git repo

git - 如何使用 git 创建一个分支并重置另一个分支?

git - 为每个部署构建在 git 中制作一个标签是一个好习惯吗?

git - 无法使用 git 配置文件进行 ssh

git - 如何恢复对 git 子模块的更改?

git - 如何单独加载项目中包含的子模块?