如何发布到.github.com?

发布于 2024-07-21 13:24:34 字数 1016 浏览 7 评论 0原文

我已阅读指南,它告诉您执行以下操作:

  1. 创建一个 .github.com 存储库
  2. 并检查它到 path/to/repo
  3. cd /path/to/repo
  4. git symbolic-ref HEAD refs/heads/gh-pages
  5. rm .git/index
  6. git clean -fdx
  7. echo "我的 GitHub 页面" > index.html
  8. git add .
  9. git commit -a -m“第一页提交”
  10. 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:

  1. create a .github.com repository
  2. check it out to path/to/repo
  3. cd /path/to/repo
  4. git symbolic-ref HEAD refs/heads/gh-pages
  5. rm .git/index
  6. git clean -fdx
  7. echo "My GitHub Page" > index.html
  8. git add .
  9. git commit -a -m "First pages commit"
  10. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

提笔落墨 2024-07-28 13:24:34

显然,随后对“origin master”的推送实际上起到了作用! 不过,指南中没有记录这一点。

Apparently subsequent pushes to "origin master" actually do the trick! It's not documented in the guide, though.

甜警司 2024-07-28 13:24:34

正如 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.

-小熊_ 2024-07-28 13:24:34

要处理新的远程存储库签出的分支,您首先需要在本地创建分支。 以下是“gh-pages”分支的示例:

git checkout --track -b gh-pages origin/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:

git checkout --track -b gh-pages origin/gh-pages

More details in this article "Migrating project websites to github pages"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文