合并 git 个存储库的最佳方式
best way to combine git repositories
我正在寻找在新项目中使用单个或多个 git(hub) 存储库的最佳方法,以便我可以从原始 git 源中提取更新。
所以如果我有 foo.git 和 bar.git 并且我开始一个新项目 baz.git。在 baz 存储库中拥有 foo 和 bar 的最佳方式是什么?我应该将它们克隆到新目录中还是使用 git 合并或其他方式?
我不想丢失 foo 和 bar 的历史记录和与原始存储库的连接,因为我仍然想在需要时提取更新。
谢谢。
看来你要找的是git子模块
http://git-scm.com/docs/git-submodule :
Submodules allow foreign repositories to be embedded within a
dedicated subdirectory of the source tree, always pointed at a
particular commit.
They are not to be confused with remotes, which are meant mainly for
branches of the same project; submodules are meant for different
projects you would like to make part of your source tree, while the
history of the two projects still stays completely independent and you
cannot modify the contents of the submodule from within the main
project.
关于子模块的更多信息:http://git-scm.com/book/en/v2/Git-Tools-Submodules
我正在寻找在新项目中使用单个或多个 git(hub) 存储库的最佳方法,以便我可以从原始 git 源中提取更新。
所以如果我有 foo.git 和 bar.git 并且我开始一个新项目 baz.git。在 baz 存储库中拥有 foo 和 bar 的最佳方式是什么?我应该将它们克隆到新目录中还是使用 git 合并或其他方式?
我不想丢失 foo 和 bar 的历史记录和与原始存储库的连接,因为我仍然想在需要时提取更新。
谢谢。
看来你要找的是git子模块
http://git-scm.com/docs/git-submodule :
Submodules allow foreign repositories to be embedded within a dedicated subdirectory of the source tree, always pointed at a particular commit.
They are not to be confused with remotes, which are meant mainly for branches of the same project; submodules are meant for different projects you would like to make part of your source tree, while the history of the two projects still stays completely independent and you cannot modify the contents of the submodule from within the main project.
关于子模块的更多信息:http://git-scm.com/book/en/v2/Git-Tools-Submodules