Recently I move my blog from vps to github with hexo.It’s first time to use hexo.It’s good but I have a question with how to deal with write my blog in different computer.The code of hexo to deploy in github is not with the source code.With the google,I found a really method.
In baidu,all method is say to create a branch to save the code.I don’t like it.I want to create a private repository.
Let’s go!
BACK_UP
create a private repository in github
nothing to say.
create a local repository
go to you blog folder,delete all gits of themes.
rm -rf ./themes/*/.git/
create a local git repository
git init
create a file named .gitignore,put it in the root of blog.content is
.DS_Store
Thumbs.db
db.json
*.log
node_modules/
public/
.deploy*/
than create a file name CNAME in source,content is your domain.
push it to your private repository
git remote add origin https://github.com/<yourname>/myblog.git
git add .
git commit -m "myblog"
git push -u origin master
all the backup is over
write in other computer
build the environment
install node.js and git
install hexo
create folder name hexo and go to it
npm install -g hexo
pull your blog
git clone https://github.com/<yourname>/myblog.git
write a new article
init the hexo environment
WARRING!!! DON’T USE hexo init
,because the hexo init will rewrite your blog.
USE:
npm install
the create a new article
hexo new "test"
push it to github and publish
publish it to hexo
hexo clean
hexo g
hexo s
hexo d
push it to github
git status
git add .
git commit
git push
update the hexo
exec these commands to update the hexo
git fetch -all # pull all files from github to locat
git reset --hard origin/master #Force local content to just sync git cloud content
the reason for don’t use pull is there are many files in local.Reset does nothing to the file being pulled.Use pull may take some mistake because of the target.
END!
ENjoy the github!