hexo version control

使用hexo搭建博客,若是換了電腦怎麼更新博客?若是你有備份源文件那還好,可是每次都要備份感受太麻煩了。 這裏介紹一種方法就是使用github分支。一個分支用來存放Hexo生成的網站原始的文件,另外一個分支用來存放生成的靜態網頁。 網上也有其餘的方法,你們能夠去搜一下,本身看看哪一種適合本身,我用這種方法一方面我git命令也不太熟,因此想多寫寫,多學學。node

先刪除主題文件下的.git文件, 能夠直接刪除或者執行下面的命令git

$ rm -rf .git
複製代碼

而後在本地博客文件夾下邊依次輸入如下指令(部分指令由於有提示能夠本身修改下)github

$ git init
$ git checkout -b hexo
$ git remote add origin git@github.com:vonfly(你本身giuhub帳號名)/vonfly.github.io(項目名).git
$ git add .
$ git commit -m "提交說明"
$ git push origin hexo
複製代碼

執行到這裏咱們就已經把本地的源文件添加到了分支hexo上。npm

說明:博客文件夾下根目錄.gitignore(此文件的做用是所以忽略所寫的文件或者目錄,加快push速度。)能夠不修改,個人就沒有修改,若是不修改的話 在;另一臺電腦上克隆下來的博客項目就要先運行一下命令json

$ npm install
複製代碼

個人.gitignore文件內容爲 .DS_Store Thumbs.db db.json .log node_modules/ public/ .deploy/bash

固然你也能夠把node_modules/去掉,這樣在另外的電腦克隆下來的項目就不用在運行上面的命令了服務器

擴展:hexo

github常見操做和常見錯誤!

若是輸入$ git remote add origin git@github.com:vonfly(github賬號名)/vonfly.github.io(項目名).git

提示出錯信息:fatal: remote origin already exists.app

解決辦法以下: 一、先輸入git remote rm origin
二、再輸入 git remote add origin git@github.com:vonfly/vonfly.github.io.git 就不會報錯了!網站

若是輸入$ git remote rm origin 仍是報錯的話,

error: Could not remove config section 'remote.origin'. 咱們須要修改gitconfig文件的內容 四、找到你的github的安裝路徑,個人是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc 五、找到一個名爲gitconfig的文件,打開它把裏面的[remote "origin"]那一行刪掉就行了!

若是輸入$ git push origin master

提示出錯信息:error:failed to push som refs to ....... 解決辦法以下: 一、先輸入git pull origin master //先把遠程服務器github上面的文件拉下來
二、再輸入 git push origin master 三、若是出現報錯 fatal: Couldn't find remote ref master或者fatal: 'origin' does not appear to be a git repository以及fatal: Could not read from remote repository. 四、則須要從新輸入$ git remote add origin git@github.com:vonfly/vonfly.github.io.git

相關文章
相關標籤/搜索