如何发布到.github.com?
我已阅读指南,它告诉您执行以下操作:
- 创建一个 .github.com 存储库
- 并检查它到
path/to/repo
- cd /path/to/repo
- git symbolic-ref HEAD refs/heads/gh-pages
- rm .git/index
- git clean -fdx
- echo "我的 GitHub 页面" > index.html
- git add .
- git commit -a -m“第一页提交”
- git Push origin gh-pages
我已经做到了。 然后页面就显示出来了。 然后我转移到另一台计算机并再次检查存储库。 现在我的本地有一个“master
”分支,但没有“gh-pages
”。 按照上面的步骤 3-6,我在该分支中没有任何文件。 如何将文件从“master
”获取到将发布到 GitHub 的分支?
我尝试了 git checkout master && git push origin gh-pages 但这会产生
error: src refspec gh-pages does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push to '[email protected]:<me>/<me>.github.com.git'
I've read the guide, which tells you to do the following:
- create a .github.com repository
- check it out to
path/to/repo
- cd /path/to/repo
- git symbolic-ref HEAD refs/heads/gh-pages
- rm .git/index
- git clean -fdx
- echo "My GitHub Page" > index.html
- git add .
- git commit -a -m "First pages commit"
- git push origin gh-pages
I've done that. And the page shows up. Then I moved to a different computer and checked out the repository again. Now I have a "master
" branch in my local, but no "gh-pages
." And following steps 3-6 above leaves me with no files in that branch. How do I get the files from "master
" into the branch that will publish to GitHub?
I tried git checkout master && git push origin gh-pages
but that yields
error: src refspec gh-pages does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push to '[email protected]:<me>/<me>.github.com.git'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
显然,随后对“
origin master
”的推送实际上起到了作用! 不过,指南中没有记录这一点。Apparently subsequent pushes to "
origin master
" actually do the trick! It's not documented in the guide, though.正如 Gaius 所说,您正在遵循“项目页面”的说明,但您并不是在尝试创建项目页面,而是在尝试创建用户页面。 创建用户页面要容易得多 - 您只需创建一个“.github.com”存储库,然后将您的网站文件推送到其主分支,就像任何其他正常项目一样。
您尝试遵循的说明是将包含网站文件的并行分支添加到现有项目中。 我们不想让您在项目中添加“网站”子目录或其他内容,因此我们让您创建一个全新的分支并将您的网站推送到该不相关的分支 - 因此存在 Git 诡计。
As Gaius says, you are following the directions for 'Project Pages', but you are not trying to create a project page, you are trying to create a user page. Creating a user page is much easier - you just create a '.github.com' repository then push your website files to it's master branch, like you would any other normal project.
The instructions you are trying to follow are for adding a parallel branch containing website files to an already existing project. We don't want to make you add a 'website' subdirectory or something to your project, so instead we have you create a completely new branch and push your website to that unrelated branch - thus the Git trickery there.
要处理新的远程存储库签出的分支,您首先需要在本地创建分支。 以下是“
gh-pages
”分支的示例:本文中的更多详细信息"将项目网站迁移到 github 页面"
To work on a branch of a fresh remote repository checkout you will first need to create the branch locally. Here is an example for a “
gh-pages
” branch:More details in this article "Migrating project websites to github pages"