【发布时间】:2014-03-05 01:40:27
【问题描述】:
使用 Git,我想在我的项目中包含一些常见的 JS/CSS 库和/或实用方法(即来自另一个 repo 的特定文件),我希望他们这样做'总是最新的。我真的不想要整个远程存储库。如果我可以处理远程文件的“本地副本”并将更改推送回去,那就太好了。
一个有点平行的例子:在 ASP.NET 中,我会通过引用 ("remote") 其他库的 .dll 文件(没有“复制本地”)来做到这一点,这样每当我重新编译了我的项目已经指向最新版本的外部库。
示例场景
我的项目是...MyProject,我只想要来自外部存储库ExternalLibrary 和External2 的几个文件。我不想在其他地方克隆每个存储库并将文件复制粘贴到我的存储库中。如果我对 MyProject/scripts/common1.js 进行改进,我想将其推回 ExternalLibrary。
-
我的项目/
- index.html
-
脚本/
- mycode.js
- otherplugin.js
- common1.js
- plugin2.js
-
样式/
- mystyle.css
- common.css
-
外部图书馆/
- common1.js
- plugin1.js
- plugin2.js
- 一堆杂七杂八的...
-
外部2/
- common.css
- 一堆杂七杂八的...
相关参考资料:
- Git: how to work with multiple repositories?
- How to checkout only one file from git repository?
- Get file from other developer local GIT and add to main repository
- Can a git repository be created where branches are clones from other repositories?
- http://www.kernel.org/pub/software/scm/git/docs/gitworkflows.html
【问题讨论】:
-
这个解释看起来很有希望...stackoverflow.com/questions/2657899/…
-
看看子模块。
-
@MartinshShaiters 我刚刚遇到了一些让我得出这个结论的事情
-
也许这就是答案?我得再读一读……stackoverflow.com/a/4170965/1037948
标签: git workflow organization