创建私有仓库

github 上创建名为: hexoblog 的私有仓库,步骤略。

删除新增加主题的 .git 文件夹

Hexo 中添加的第三方主题 pure 包含有 .git 文件夹,如果这个文件夹没有删除的话,该主题内的所有内容都不能上传仓库中,所以需要先把该文件夹删除掉。

显示 pure 文件夹的内容,包含隐藏文件夹:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ ls ./themes/pure -la

total 84
drwxr-xr-x 9 yoda yoda 4096 2月 2 22:59 .
drwxr-xr-x 4 yoda yoda 4096 2月 2 22:49 ..
-rw-r--r-- 1 yoda yoda 6491 2月 3 11:49 _config.yml
-rw-r--r-- 1 yoda yoda 6350 2月 2 22:59 _config.yml.example
drwxr-xr-x 8 yoda yoda 4096 2月 2 22:59 .git
-rw-r--r-- 1 yoda yoda 28 2月 3 14:11 .gitignore
drwxr-xr-x 2 yoda yoda 4096 2月 2 22:59 languages
drwxr-xr-x 7 yoda yoda 4096 2月 2 22:59 layout
-rw-r--r-- 1 yoda yoda 1053 2月 2 22:59 LICENSE
-rw-r--r-- 1 yoda yoda 102 2月 2 22:59 package.json
-rw-r--r-- 1 yoda yoda 9523 2月 2 22:59 README.cn.md
-rw-r--r-- 1 yoda yoda 4164 2月 2 22:59 README.md
drwxr-xr-x 2 yoda yoda 4096 2月 2 22:59 screenshot
drwxr-xr-x 2 yoda yoda 4096 2月 2 22:59 scripts
drwxr-xr-x 6 yoda yoda 4096 2月 2 22:59 source
drwxr-xr-x 10 yoda yoda 4096 2月 2 22:59 _source

删除 .git 文件夹

1
$ rm ./themes/pure/.git -rf

上传项目到 github

初始化本地仓库

1
$ git init

添加远程仓库地址

1
$ git remote add origin git@github.com:hujiyi/hexoblog.git

添加要提交的文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ git add .
warning: adding embedded git repository: themes/pure
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint: git submodule add <url> themes/pure
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: git rm --cached themes/pure
hint:
hint: See "git help submodule" for more information.

添加提交注释信息

1
2
3
4
5
6
7
$ git commit -m "init"
[master (root-commit) 3b6c260] init
105 files changed, 8951 insertions(+)
create mode 100644 .gitignore

create mode 100644 yarn.lock

提交到 master 分支

1
$ git push origin master

撰写完后如何再次同步

1
2
3
git add .
git commit -m "这里填写你本次提交的备注,内容随意"
git push origin 分支名

取回远程主机某个分支的更新

1
git pull

总结

总的来说,这样可以来回控制你的版本,只要善用 git,你可以在任意电脑撰写你的博客。控制你的项目。

所以,部署完项目后A电脑和B电脑部署区别如下

A:

1
2
3
git add .
git commit -m "这里填写你本次提交的备注,内容随意"
git push origin 分支名

B:

1
2
3
4
5
6
git pull
hexo new 文章名
hexo g -d
git add .
git commit -m "这里填写你本次提交的备注,内容随意"
git push origin 分支名

A:

1
2
3
4
5
6
git pull
hexo new 文章名
hexo g -d
git add .
git commit -m "这里填写你本次提交的备注,内容随意"
git push origin 分支名

===END===