hexo博客源码备份与恢复



%% 先给出要点


# 备份

git init

echo "node_modules/" > .gitignore
echo "public/" >> .gitignore
echo ".deploy_git" >> .gitignore

git checkout -b hexo

git add .
git commit -m "initial commit"

git remote add origin git@github.com:speedoops/speedoops.github.io.git
git push -u origin hexo


# 恢复

git clone -b hexo --single-branch  git@github.com:speedoops/speedoops.github.io.git
cd speedoops.github.io.git
cnpm install

git clone https://github.com/tufu9441/maupassant-hexo.git themes/maupassant



%% 再记录下详细的过程


eval `ssh-agent`
ssh-add


WARN No layout: about/index.html
原因是theme之前是单独clone的,所以备份时theme实际没有备份,重新clone取theme即可



从服务器的仓库中获取代码,和本地代码合并。(与服务器交互,从服务器上下载最新代码,等同于: Git fetch + Git merge)
从其它的版本库(既可以是远程的也可以是本地的)将代码更新到本地,例如:“git pull origin master ”就是将origin这个版本库的代码更新到本地的master主分支。

git pull  username@ipaddr:远端repository名远端分支名 本地分支名。

将本地commit的代码更新到远程版本库中,例如 “git push origin”就会将本地的代码更新到名为orgin的远程版本库中。

git push  username@ipaddr:远端repository名本地分支名 远端分支名


如果我们往一个非空的目录下 clone git 项目,就会提示错误信息:

fatal: destination path '.' already exists and is not an empty directory.

解决的办法是:

1. 进入非空目录,假设是 /workdir/proj1

2. git clone --no-checkout https://git.oschina.net/NextApp/platform.git tmp

3. mv tmp/.git .   #将 tmp 目录下的 .git 目录移到当前目录

4. rmdir tmp

5. git reset --hard HEAD

然后就可以进行各种正常操作了。


git add README hello.php

git status
git status -s

git diff 命令显示已写入缓存与已修改但尚未写入缓存的改动的区别。git diff 有两个主要的应用场景。
  • 尚未缓存的改动:git diff
  • 查看已缓存的改动: git diff --cached
  • 查看已缓存的与未缓存的所有改动:git diff HEAD
  • 显示摘要而非整个 diff:git diff --stat

$ git config --global user.name 'runoob'

$ git config --global user.email test@runoob.com

git commit -m '第一次版本提交'

git commit -am '修改 hello.php 文件'

git rm  --cached README   # 保留工作区文件

git rm hello.php  # 同时删除本地文件
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值