Git 操作示例
以 https://github.com/xulong0826/blog-code
为例
克隆远程仓库
1
| git clone https://github.com/xulong0826/blog-code
|
拉取更新
查看远程仓库地址
修改远程仓库地址
删除指定的远程仓库地址:
1
| git remote set-url --delete (--push) origin https://github.com/xulong0826/blog-code.git
|
添加新的远程仓库地址:
1
| git remote set-url --add origin https://github.com/xulong0826/blog-code.git
|
添加文件到暂存区
添加所有更改:
单独添加指定文件:
提交更改
1
| git commit -m "update the project"
|
推送更改到远程分支
注意:
Hexo 配置
安装 Hexo Git 部署插件
1
| npm install hexo-deployer-git --save
|
配置 _config.yml
文件
在 _config.yml
文件中添加以下内容:
1 2 3 4
| deploy: type: git repo: https://github.com/xulong0826/blog branch: main
|
部署
1 2 3 4 5 6 7
| npm install
npm run clean
npm run deploy (hexo deploy)
|
通过以上操作,你可以顺利完成 Git 和 Hexo 的配置与更新部署。如果还有其他问题,可以随时补充说明!