简体   繁体   English

将gh-pages分支从一个存储库复制到另一个存储库

[英]Copying gh-pages branch from one repository to another repository

My GitHub org is https://github.com/Obrary . 我的GitHub组织是https://github.com/Obrary There, I have 100s of open designs for products. 那里,我有100多种产品的开放设计。 Each is a project. 每个都是一个项目。 I want each to have a GitHub page for the project. 我希望每个人都有该项目的GitHub页面。

I created a simple GitHub page for one of the projects. 我为其中一个项目创建了一个简单的GitHub页面。 See http://obrary.github.io/Alex-Chair/ . 参见http://obrary.github.io/Alex-Chair/ The page is created so that I can add it to any projects gh-pages branch and it will work for the new project. 该页面已创建,因此我可以将其添加到任何项目gh-pages分支中,并将其用于新项目。 To see that in action, http://obrary.github.io/Alexey-Surfboard-Rack/ . 要查看实际效果,请访问http://obrary.github.io/Alexey-Surfboard-Rack/

Now I want to copy the gh-pages branch from /Alex-Chair to all my other projects. 现在,我要将gh-pages分支从/ Alex-Chair复制到所有其他项目。 In going through the help and examples, I've seen a lot of information about copying branches with a repo or copying repos in whole. 在阅读帮助和示例时,我已经看到了很多有关使用仓库复制分支或整体复制仓库的信息。 But I haven't found examples on how to copy a branch from repo A to repo B. 但是我还没有找到如何将分支从仓库A复制到仓库B的示例。

Here's the current command line that I've got. 这是我当前拥有的命令行。 But it fails because the clone command only works at the repo level (or so I think). 但是它失败了,因为clone命令仅在仓库级别上起作用(或者我认为是这样)。

    git checkout --orphan gh-pages
    git rm --cached -r .
    git clone --bare https://github.com/Obrary/Alex-Chair/tree/gh-pages

Thanks 谢谢

Try this: 尝试这个:

First make sure there is a gh-pages branch in the repo you want to push to. 首先,请确保您要推送的回购中有一个gh-pages分支。

From the Alex-Chair gh-pages branch: 从Alex-Chair gh-pages分支中:

git push -f [new repo url] gh-pages

Or, add a new remote like in this answer : (using Obrary/memes as an example) 或者,在此答案中添加一个新的遥控器:(以Obrary / memes为例)

git remote add memes https://github.com/Obrary/memes
git push --force memes gh-pages

You want to be careful with force , but in this case what you want to do (completely override the upstream with local files) is exactly what force will do. 您要谨慎使用force ,但是在这种情况下,您要执行的操作(完全用本地文件覆盖上游)就是您要执行的操作。

Hope that helps! 希望有帮助!

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

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