doc: update docs/git.md

This commit is contained in:
jaywcjlove 2023-08-15 00:11:22 +08:00
parent 3c2e988059
commit 4020036f93

@ -389,21 +389,8 @@ $ git mv [existing-path] [new-path]
$ git log --stat -M $ git log --stat -M
``` ```
### git 配置 ssh 代理
<!--rehype:wrap-class=col-span-2-->
```bash
$ cat ~/.ssh/config
Host gitlab.com
# 直接使用 sh**socks 提供的 socks5 代理端口
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
Host github.com
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
```
<!--rehype:className=wrap-text-->
### .gitattributes ### .gitattributes
<!--rehype:wrap-class=col-span-2 row-span-2-->
```ini ```ini
# 设置默认行为,以防人们没有设置 core.autocrlf # 设置默认行为,以防人们没有设置 core.autocrlf
@ -435,6 +422,19 @@ special-vendored-path/* linguist-vendored
*.rb linguist-language=Java *.rb linguist-language=Java
``` ```
### git 配置 ssh 代理
```bash
$ cat ~/.ssh/config
Host gitlab.com
# 直接使用 sh**socks 提供的 socks5 代理端口
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
Host github.com
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
```
<!--rehype:className=wrap-text-->
Git 技巧 Git 技巧
------ ------
@ -964,6 +964,7 @@ git 代码统计
--- ---
### 查看 git 上的个人代码量 ### 查看 git 上的个人代码量
<!--rehype:wrap-class=row-span-2-->
- `username` 需要改成自己的 - `username` 需要改成自己的
@ -971,8 +972,10 @@ git 代码统计
git log --author="username" --pretty=tformat: --numstat | awk \ git log --author="username" --pretty=tformat: --numstat | awk \
'{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' - '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -
``` ```
<!--rehype:className=wrap-text-->
### 统计每个人增删行数 ### 统计每个人增删行数
<!--rehype:wrap-class=row-span-2-->
```bash ```bash
git log --format='%aN' | sort -u |\ git log --format='%aN' | sort -u |\
@ -980,6 +983,7 @@ git log --format='%aN' | sort -u |\
git log --author="$name" --pretty=tformat: --numstat | awk \ git log --author="$name" --pretty=tformat: --numstat | awk \
'{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done
``` ```
<!--rehype:className=wrap-text-->
### 查看仓库提交者排名 ### 查看仓库提交者排名
@ -988,6 +992,7 @@ git log --format='%aN' | sort -u |\
```bash ```bash
git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 10 git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 10
``` ```
<!--rehype:className=wrap-text-->
### 提交数统计 ### 提交数统计