简体   繁体   English

Git-模板仓库进入新仓库

[英]Git - template repo pull into new repo

I have a template project set-up that I use for a lot of projects as a starting point. 我有一个模板项目设置,可将其用于许多项目。 It has lot of custom code for various things. 它为各种事物提供了许多自定义代码。 (It's php not that this really matters). (这不是php,这真的不重要)。 Normally I'd just copy this template project into a new folder and begin working on an actual project. 通常,我只是将此模板项目复制到一个新文件夹中,然后开始处理实际项目。 This actual project would then be in a git repo. 然后,这个实际项目将在git repo中。

Now I want to start storing my template project in a git repo, so I can track changes better and try things out in branches. 现在,我想开始将模板项目存储在git repo中,这样我就可以更好地跟踪更改并在分支中进行尝试。 What's the best way of going about this so that I could have repos for actual projects that could use this template? 最好的解决方法是什么,以便我可以为可以使用此模板的实际项目提供回购协议?
I thought about composer with a private repo, but this situation could also apply to some iOS templates I have. 我考虑过使用私人存储库的作曲家,但这种情况也可能适用于我拥有的某些iOS模板。 I could obviously then use Pods etc. for the iOS stuff, but is there a way to do this simply in Git? 我显然可以将Pods等用于iOS设备,但是有没有办法在Git中简单地做到这一点?
IE have repos that reference another repo, but when I commit the actual project it doesn't have an effect on the template? IE有回购,它引用了另一个回购,但是当我提交实际项目时,它对模板没有影响吗?

IE have repos that reference another repo, but when I commit the actual project it doesn't have an effect on the template? IE有回购,它引用了另一个回购,但是当我提交实际项目时,它对模板没有影响吗?

The simplest way is to clone your template repo, and then replace the remote ' origin ' with the url of a new empty repo: 最简单的方法是克隆您的模板存储库,然后将远程' origin '替换为新的空存储库的url:

git clone /url/to/template mynewrepo
cd mynewrepo
git remote set-url origin /url/of/new/empty/repo
git push -u origin master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM