【发布时间】:2012-02-02 02:33:03
【问题描述】:
我想知道这是否可行...
假设我有一个类似的项目模板:
.
+ resources/
+ images/
1.png
2.png
我想将此项目用作其他项目的模板,因此它们基本上是从模板中“克隆”出来的,但作为单独的存储库进行维护。
但是,我仍然希望能够在更新发生时从模板中提取更新(但不关心推送)。
子模块或子树合并似乎不适合这里,因为它没有克隆到子目录中;它被有效地“映射”到根目录或新项目。
我认为可以工作的一个是这样的:
#setup project
mkdir proj1
cd proj1
git init.
touch .gitignore
git add .gitignore
git commit -m "Initial Commit"
#setup main repo
git remote add origin git@server:proj1.git
git push origin master
# load template repo as separate remote
git remote add -f template git@server:template.git
# import into current master
# here I guess I have the choice of either:
git merge template/master
# OR
git rebase template/master
然后在模板项目上更新:
.
+ resources/
+ images/
1.png
2.png
3.png <-added file
我应该能够执行git pull template master 以从模板中提取更改并重复最后的合并/变基步骤以集成到项目中。
这是正确的方法,还是有更好的方法来做到这一点?
我会在这条路上遇到一些麻烦吗?
谢谢
【问题讨论】: