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

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

用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 

添加需要指定文件,如:

git add . --all

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


连接成功了么,连接成功后先切换到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


首先,你的命令有问题。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
【热门文章】
【热门文章】