运行: hexo deploy 命令时候,报错 bad config file line 1 in .git/config,下面是错误信息,
在git bash下面运行 hexo deploy
1 | $ hexo deploy |
分析错误信息,找原因
看上面的错误信息,应该是 github 的配置信息有问题, 用命令 cd .deploy/.git/
进入该目录,用编辑器打开config文件, 里面居然啥内容都没有
我们用命令验证下,在 git bash 上用命令 cd .deploy
, 进入到 .deploy 目录, 然后运行 git status
,出现下面的错误信息:1
2
3
4$ cd .deploy/
Administrator@CHINA-5CBAE4A74 /e/jinshankuaip
$ git status
fatal: bad config file line 1 in .git/config
说明config文件确实是啥内容也没有,好了,既然找到了原因,
那么解决办法就很简单了,
找到你的另外的github.com的项目,到项目文件下复制一份 config 文件的内容到 .deploy/.git/config 里面,保存
下面是config的内容:1
2
3
4
5
6
7
8
9
10
11
12
13
14[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[remote "origin"]
url = https://github.com/bigxing/bigxing.github.io.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = https://github.com/bigxing/bigxing.github.io.git
merge = refs/heads/master
注意:把上面的 url 和 remote 改成你自己的 git, 我的是 https://github.com/bigxing/bigxing.github.io.git
验证配置信息:
在 git bash 下面敲命令 git status
, 就会出现很多信息1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working
#
# modified: 2014/10/31/hello-world/index.html
# modified: 2014/11/06/tech-employee-improve/index.html
# modified: 2014/11/20/http-guide-note-one/index.html
# modified: about/index.html
# modified: archives/2014/10/index.html
# modified: archives/2014/11/index.html
# modified: archives/2014/index.html
# modified: archives/index.html
# modified: "categories/\346\234\215\345\212\241\345\231\25
# modified: "categories/\346\235\202\350\201\212/index.html
# modified: index.html
# modified: tags/http/index.html
# modified: "tags/\346\200\235\350\200\203/index.html"
# modified: "tags/\346\212\200\346\234\257/index.html"
# modified: "tags/\346\234\215\345\212\241\345\231\250/inde
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
说明添加 config 的内容,成功了。
最后在 git bash 下敲如下命令1
2
3
4
5
6$ git deploy
Branch master set up to track remote branch master from https://github.com/bigxing/bigxing.github.io.git.
To https://github.com/bigxing/bigxing.github.io.git
55d1451...0ab67f master -> master
[info] Deploy done: github
就顺利的把内容commit到远程github上了
好了,最后,你可以愉快的浏览你的网站内容了