[英]GitHub - how to clone a repository into multiple repositories and push each to GitHub
您的问题有点令人困惑。 正如评论所言,听起来这就像是要分支而不是存储库,如果这一切都是为了您自己。 如果出于某种原因您正试图派生代码,并且它们需要使用不同的存储库,则任何推/拉操作的默认远程都将是origin
。 默认情况下, origin
指向要克隆的远程对象,但是它没有什么特别之处,可以使用git remote
命令对其进行更改。
例如:
git clone https://github.com/ParsePlatform/parse-server-example parse-server-example1
cd parse-server-example1
git remote rm origin
git remote add origin https://github.com/ParsePlatform/parse-server-example1
(repeat for 2 and 3)
会实现您的要求。 如果已经有不同的派生,则可以使用其他名称创建遥控器,并在“ git push”中明确说明要推送到的遥控器/分支。
例如:
cd parse-server-example1
git remote add example2 https://github.com/ParsePlatform/parse-server-example2
git push example2 master
(repeat for as many different repos/names as you want, ie.)
git remote add example1 https://github.com/ParsePlatform/parse-server-example1
会将您的(本地)example1代码推送到example2分支和(在上述之后)
git fetch example2
git checkout example2/master
(do stuff, maybe commit)
git checkout example1/master
会在本地不同的叉子之间切换。 通常,这是一种更好的工作方式,除非出于某种原因需要将多个副本同时克隆到不同目录中。
感谢driusan的回答,我认为我对这个问题的回答是:将上游仓库: OLD_REPO_URL克隆到我自己在GitHub上的帐户的新仓库中:
https://github.com/{MY_ACCOUNT}/parse-server-example-APP1
https://github.com/{MY_ACCOUNT}/parse-server-example-APP2
https://github.com/{MY_ACCOUNT}/parse-server-example-APP3
通过以下命令:
git clone https://github.com/ParsePlatform/parse-server-example parse-server-example-APP1
cd parse-server-example-APP1
git remote rm origin
git remote add origin https://github.com/{MY_ACCOUNT}/parse-server-example-APP1
(repeat for 2 and 3)
现在已经创建了新的存储库,我可以使用它们中的每个并对代码进行更改。 推送代码完成后会变回原点。
如果OLD_REPO已更新,请运行以下命令来获取更新并与克隆的存储库合并更新:
cd parse-server-example-APP1
git remote add upstream https://github.com/ParsePlatform/parse-server-example
git fetch upstream
git merge upstream/master
git push
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.