title: git notes
date: 2020-03-07 01:13:12
tags:
- 工具
- hexo
categories: others
description: git tips
typora-root-url: git-notes
今天參考 http://www.reibang.com/p/55f11d8973f0 在github上github pages的倉庫下建立了一個source分支缺脉,用來存放hexo博客的md源文件注盈,用于備份和以后遷移設(shè)備備用匙奴。
首次備份到新的branch做法
-
如果不在master分支,先確保切換回master分支
git checkout master
進(jìn)入要備份的
source
文件夾-
初始化git倉庫
git init
與遠(yuǎn)程倉庫建立連接
git remote add origin git@github.com:yourname/yourname.github.io.git
- 在本地把源代碼提交到本地版本庫中
git add .
git commit -m 'add hexo-blog origin files'
- 推送到遠(yuǎn)程倉庫的名為source的新分支上面
git push origin master:source
之后每次備份新的blog文件做法
先備份md文件夾
進(jìn)入本地帶備份的
source
文件夾在本地把源代碼提交到本地版本庫中
git add .
git commit -m 'add new hexo-blog file'
-
推送到遠(yuǎn)程倉庫的名為source分支
git push origin master:source
再部署靜態(tài)文件
hexo g
hexo d