Git 常用命令和介绍

我看还有谁不动Git (qq.com)

Git 提交规范引入指南

超详细的Git提交规范引入指南 - 掘金 (juejin.cn)
约定式提交 (conventionalcommits.org)

1
2
3
4
5
6
7
8
9
10
feat - 新功能 feature  
fix - 修复 bug
docs - 文档注释
style - 代码格式(不影响代码运行的变动)
refactor - 重构、优化(既不增加新功能,也不是修复bug)
perf - 性能优化
test - 增加测试
chore - 构建过程或辅助工具的变动
revert - 回退
build - 打包

在 Terminal 中通过代理访问 GitHub

设置 Git 局部代理

如果你想在本地已有的仓库中,让 pull 或者 push 命令经过代理,就需要将 git 工具的代理设置为上一步中输入的端口(我的端口是 41091):

1
2
3
4
$ cd path/to/your/repo/
$ git config http.proxy http://127.0.0.1:41091
$ git config https.proxy https://127.0.0.1:41091
$ git config --list # 查看设置结果

注意:

  • 这里使用的是 git 工具的 局部代理(没有 --global 标示),所以仅该目录下的 git 命令会经过代理。
  • 127.0.0.1 是 localhost 的 IP 地址,如果你的代理不在同一个计算机上,就需要输入对应的 IP 地址。
  • 如果上一步选择了 SOCKS5 协议,使用以下命令:
1
2
$ git config http.proxy socks5://127.0.0.1:1090
$ git config https.proxy socks5://127.0.0.1:1090
  • 如果想要停用代理,输入以下命令:
1
2
$ git config --unset http.proxy
$ git config --unset https.proxy

设置 Git 全局代理

如果你想让 clone 命令经过代理,首先需要设置 git 工具的 全局代理

1
2
$ git config --global http.proxy http://127.0.0.1:41091
$ git config --global https.proxy https://127.0.0.1:41091

clone 完成之后,记得停用全局代理,否则之后所有的 git 命令都会经过代理:

1
2
$ git config --global --unset http.proxy
$ git config --global --unset https.proxy

如果想要在克隆的文件夹中打开局部代理,可以参照第一种情况。

下载单个 Github 文件夹(实际下载整个文件夹,速度还行)

刚写了个库 dclone,看了一眼应该是 github 上最简单的实现其他的库实现都写的特别复杂,可以让你只下载单个文件夹提升你的下载速度。

1
2
$ npm i -g dclone
$ dclone https://github.com/ykfe/egg-react-ssr/tree/dev/example/ssr-with-loadable