用Github搭建博客时,实现在线预览,无法将本地远程到Github仓库

发布于 2022-09-02 12:53:23 字数 657 浏览 16 评论 0

用Github搭建博客时,实现在线预览,无法将本地远程到Github仓库.
已在在GitHub上创建一个仓库repository,仓库名称为xuqianzheng.github.io

$ git add
Nothing specified, nothing added.
Maybe you wanted to say 'git add .'?
$ git commit -m "first post"
On branch master

Initial commit

Untracked files:
    .gitignore
    _config.yml
    package.json
    scaffolds/
    source/
    themes/

nothing added to commit but untracked files present
$ git remote add origin https://github.com/xuqianzheng/xuqianzheng.github.io.git
fatal: remote origin already exists.
$ git push origin gh-pages
error: src refspec gh-pages does not match any.
error: failed to push some refs to 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

不再让梦枯萎 2022-09-09 12:53:23

添加需要指定文件,如:

git add . --all

另: 用hexo写博客,并不是将源文件夹推上github。你应该用 hexo d 将public 文件推上 username.github.io的master分支。详细内容请自搜教程。

波浪屿的海角声 2022-09-09 12:53:23

连接成功了么,连接成功后先切换到gh-pages分支
1.(git init)
2.(git add .)
3.(git commit -m "first post")
4.(添加远程库git remote add origin https://github.com/xuqianzheng/xuqianzheng.github.io.git)
5.(git push -u origin gh-pages)
fatal: remote origin already exists.远程库已经存在 先移除远程仓库(git remote rm origin)再添加远程仓库
error: src refspec gh-pages does not match any.分支没有匹配上
error: failed to push some refs to 出现这问题要先(git pull origin gh-pages)再push

べ繥欢鉨o。 2022-09-09 12:53:23

首先,你的命令有问题。git提交命令使用如下:

$ git add . # 点的意思是把所有的修改添加到暂存区中,而你只是git add,没有添加任何东西。
$ git commit -m "first commit" # 将暂存区的修改提交到本地仓库。
...

而且,Hexo部署到Github上,其实是把hexo g生成的public文件里面的所有内容提交到*.github.io仓库中。所以也可以用git手动提交到github上面,不过很麻烦就是了。

推荐的做法是:安装hexo-deployer-git插件,配置远程部署的参数,然后使用hexo d进行部署。
这样才更方便快捷。

参数配置如下:

deploy:
  type: git
  repo: ssh://git@github.com/dkylin/dkylin.github.io.git # 最好使用SSH地址
  branch: master
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文