简体   繁体   English

如何克隆一个git项目来创建另一个仓库?

[英]How to clone a git-project to create a different repo?

I've got a Github project ( https://github.com/gbrits/yeoman-less ) that I'd like to use as a quickstart for some other projects. 我有一个Github项目( https://github.com/gbrits/yeoman-less ),我想将其用作其他一些项目的快速入门。 Each of these other projects need to get their own repo. 其他每个项目都需要获得自己的存储库。

So git clone https://github.com/gbrits/yeoman-less (alone) doesn't work, since I need to do something like change the origin after the clone to point to a different remote endpoint. 所以git clone https://github.com/gbrits/yeoman-less (单独)不起作用,因为我需要做一些类似的事情,例如在克隆后更改原点以指向另一个远程端点。

Related: hos would you create a remote origin in github from the commandline, instead of having to manually create it and then linking it up in the commandline? 相关:您可以从命令行在github中创建远程原点,而不必手动创建它,然后在命令行中将其链接起来吗?

Pretty easy it appears. 看起来很简单。

First clone 第一个克隆

git clone git://..

Optionally change name of local dir. (可选)更改本地目录的名称。

intermezzo : create new remote github repo (from website) or from command-line (see below): (from Is it possible to create a remote repo on GitHub from the CLI without opening browser? intermezzo :(从网站)或从命令行(见下文)创建新的远程github存储库:(来自可以在不打开浏览器的情况下从CLI在GitHub上创建远程存储库吗?

curl -u 'USER:PASS' https://api.github.com/user/repos -d '{"name":"REPO"}'
git remote add origin git@github.com:USER/REPO.git
git push origin master

Change origin 更改原点

git remote set-url origin git://<new repo>

And push 并推

git push -u origin master

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

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