github 如何在新的 git 分支 gh-pages 中包含来自 master 的文件 [英] github how to include files from master in new git branch gh-pages

查看:44
本文介绍了github 如何在新的 git 分支 gh-pages 中包含来自 master 的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

github 有这个功能,如果你在你的项目中创建一个新的分支 gh-pages,你可以发布项目页面".有关完整说明,请参阅 http://pages.github.com/

github has this feature where you can publish "Project Pages" if you create a new branch gh-pages in your project. For full description see http://pages.github.com/

我的项目只是 html/images,所以我只想为 master 分支服务.

My project is just html/images, so I just want to serve the master branch.

那么我如何创建一个名为 gh-pages 的新分支,它只是 master 的精确副本?某种链接操作?

so how do I create a new branch called gh-pages that is just exact copy of master? some kind of link operation?

谢谢

推荐答案

您希望 GitHub 存储库中的分支gh-pages" 与master"分支相同.最简单的解决方案是配置 git 以自动将分支master"推送到gh-pages".

You want branch 'gh-pages' in your GitHub repository to be the same as 'master' branch. The simplest solution would be to configure git to push branch 'master' to 'gh-pages' automatically.

假设您推送到的 GitHub 存储库配置为origin"远程,您可以简单地执行以下操作:

Assuming that your GitHub repository you push into is configured as 'origin' remote, you can somply do:

$ git config --add remote.origin.push +refs/heads/master:refs/heads/gh-pages

或者,如果您愿意,您可以直接编辑 .git/config 文件.

Or if you prefer you can simply edit .git/config file directly.

然后,当您执行 git pushgit push origin 时,您会将存储库中的master"分支推送到 GitHub 上的存储库中的gh-pages"分支.

Then when you do git push or git push origin you would push 'master' branch in your repository into 'gh-pages' branch into repository on GitHub.

请参阅 git-push 手册页refspec 格式的文档和说明.

See git-push manpage for documentation and description of refspec format.

这篇关于github 如何在新的 git 分支 gh-pages 中包含来自 master 的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆