在github中托管代码时出现问题

时间:2015-05-08 20:23:39

标签: git github-pages

以下是我的时间跟踪git repo:Click here!!
我想在git页面中托管该项目。所以我按照以下步骤操作:

  
      
  1. 使用名称username.github.io创建一个repo。我创建了一个新的repo akulkarni9.github.com。
  2.   
  3. 在GitHub上打开存储库页面。
  4.   
  5. 在您的资源库的右侧边栏中,点击设置。
  6.   
  7. 单击“自动页面生成器”按钮并在标记编辑器中创建我的内容。
  8.   
  9. 点击继续展示布局按钮
  10.   
  11. 在我们的主题中预览您的内容。
  12.   
  13. 找到喜欢的主题后,请点击发布页面。
  14.   

我确实完成了这些步骤中提到的事情。当我在浏览器中打开"qq-upload-list-selector"时,该项目未被托管 然后我执行了以下命令:

akulkarni.github.io

输出是:

cd to repository in local system  
git fetch origin  

然后我执行了这个命令:

remote: Counting objects: 56, done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 56 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (56/56), done.
From https://github.com/akulkarni9/akulkarni9.github.io
   7ac8179..651c795  master     -> origin/master  

我收到了一个错误:

git checkout gh-pages  

我哪里出错了?

3 个答案:

答案 0 :(得分:2)

您的存储库只有master分支,它没有gh-pages分支。这就是错误所说的。

如果要在本地创建该分支,则应执行以下操作:

git checkout -b gh-pages

而不是:

git checkout gh-pages

或者,正如documentation建议:

git checkout --orphan gh-pages

这将创建没有任何父母的分支。

<强>更新

现在您已在本地设置gh-pages分支,您需要向其添加内容并将分支推送到远程存储库。您可以按照以下方式执行此操作(取自文档):

echo "My Page" > index.html
git add index.html
git commit -a -m "First pages commit"
git push origin gh-pages

如果您已完成上述操作。您将有index.html个文件,其中包含My Page个内容。只需编辑该文件(按您希望的那样)并推送您的更改:

git add index.html
git commit -a -m "Updated the index.html file."
git push origin gh-pages

应该这样做。另外,请注意文档的最后一行:

  

推送到gh-pages分支后,您的项目页面网站将在http(s)://<username>.github.io/<projectname>

提供

更新,第二部分

如果您在完成所有这些操作后仍然遇到问题,可以选择创建项目页面with the automatic generator

更新,第III部分

好的,所以不要在Github网站中创建gh-pages分支,而是在要显示为项目页面的存储库中创建该分支。

因此,假设您希望将Time Tracker项目作为项目页面:

  1. 在TimeTracker项目中创建一个gh-pages分支(就像您之前在*.github.io存储库中所做的那样)。
  2. 添加您的内容。
  3. 将其推送到Github。
  4. 现在访问:https://akulkarni9.github.io/TimeTracker

答案 1 :(得分:0)

收到消息后可以做的一些事情 错误:pathspec&#39; gh-pages&#39;与git已知的任何文件都不匹配。

来自Git Bash:

git branch -a  (show all branches, local and remote).  

如果您的分支 branch-name 未出现在本地或远程列表下,则表示 branch-name 在本地或远程存储库中不存在。 /> 在本地创建w / git checkout -b branch-name

如果发现所需的分支是远程的,您可以使用

进行检查
git checkout -b branch-name origin/branch-name

Good source for Git documentation.
Git cheat sheet for quick reference.

此外,当GitHub页面弃用.com子域名时,您创建了repo akulkarni9.github.com 。您应该尝试将repo重新创建为 akulkarni9.github.io

答案 2 :(得分:0)

你确定你完成了最后一步吗?点击&#34;发布页面&#34;按钮?

当您点击此按钮时,GitHub将创建一个新的分支,并在其中提交设置&amp;项目页面后面的代码。创建页面后,您将能够在主项目页面的分支选择器中看到它。

例如,如果您查看我的Magic8Ball project,您就可以找到该项目的gh-pages branch GitHub page

在GitHub中配置分支后,拉出之前克隆的项目,您将能够看到新的gh-pages分支到达:

> git pull
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 11 (delta 0), reused 0 (delta 0), pack-reused 7
Unpacking objects: 100% (11/11), done.
From github.com:bitcrazed/Magic8Ball
 * [new branch]      gh-pages   -> origin/gh-pages
Already up-to-date.

您现在可以签出新的gh-pages分支:

> git checkout -t origin/gh-pages
Branch gh-pages set up to track remote branch gh-pages from origin.
Switched to a new branch 'gh-pages'

HTH。

相关问题