Git常见命令

总结了一下git常见指令

批量删除 .DS_Store

1
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch

增加

1
2
3
4
git add readme # 添加 readme 文件
git add . [[后面加一个]]“.”,匹配所有的文件
git add -u --update [[update]] tracked files 更新所有改变的文件,即提交所有变化的文件
git add -A   --all  # add changes from all tracked and untracked files   提交已被修改和已被删除文件,但是不包括新的文件

修改

1
git mv readme [[]] # 重命名文件

配置

  设置 git 的 user name 和 email

1
2
git config --global user.name "gclm"
git config --global user.email "1719982754@qq.com"

  生成秘钥

1
ssh-keygen -t rsa -C "1719982754@qq.com"

忽略警告

  设置core.autocrlf=false,windows也用LF换行。

1
git config --global core.autocrlf false

  设置一个.editorconfig 来保证文件都是 LF 结尾。除了记事本,其他编辑器都可以正常编辑

git 设置和取消代理

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# 设置ss
git config --global http.proxy 'socks5://127.0.0.1:1080'

# 设置代理
git config --global http.proxy 'http://127.0.0.1:7890'
git config --global https.proxy 'http://127.0.0.1:7890'

# 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy

# 代理镜像配置
git config --global url."https://hub.fastgit.org".insteadOf https://github.com
git config --global url."https://mirror.ghproxy.com/https://github.com".insteadOf https://github.com

客户端配置

  https://juejin.im/post/5bd5a08cf265da0add520772#heading-0