博客网站云服务器配置流程
# 问题描述
自己写了一些技术博客,之后凑巧买了一台云服务器,因此打算在服务器上面部署自己的博客网站
# 解决方法
首先使用的是 xugaoyi/vuepress-theme-vdoing: 🚀一款简洁高效的VuePress知识管理&博客(blog)主题 (opens new window) 博客模板。配置好之后可以在本地运行,也可以配置在github上面。
配置在GitHub上面的可以看对应的记录贴 “GithubPage配置” 。
在服务器上面配置时,考虑到本机和服务器之间传文件不方便,因此使用github作为中转。正好因为配置github page也上传了对应文件。
不过有个问题,就是commit的问题 。因为这个博客模板要上传 “\docs.vuepress\dist”中的内容,而这个文件夹每次构建都会删除全部内容,重新生成。导致 .git 文件每次都要重新生成。
因此通过先pull拉取,之后以本地为基准自动合并,最后push上传的方式解决。
具体代码如下
cd docs/.vuepress/dist
git init
git add -A
git commit -m "change blog contents"
git remote add origin https://github.com/myeeygo/myeeygo.github.io.git
git pull origin master --allow-unrelated-histories -X ours --no-edit
git -c http.proxy=http://127.0.0.1:7897 push -u origin master
pause
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
其中最重要的一行是“git pull origin master --allow-unrelated-histories -X ours --no-edit”。
之后从云服务器拉取github的。
第一次拉取可以使用
git clone bala……bala.git
1
之后更新使用
git fetch origin && git reset --hard origin/master
1
使用了 git reset 是因为在构建时进行了自动合并,一些信息被改变了。
之后就得到了最新的博客内容