设置

# 自动保存http帐号密码
git config --global credential.helper store

版本控制

  • git difftool 1234 4321 file -y 比较不同提交差异
  • git commit --amend 追加提交

log

git log --since=2.weeks --until=2.days
git log --since='2020-05-01' --until='2020-06-01'
git log --author=kuang-R
# 正则查找提交说明
git log --grep "update"
# 查找添加或移除某个特定函数的提交
git log -Sfunction_name
# --all-match

tag

git tag -l 'v1.8*'
# annotated
git tag -a v1.0 -m"my version 1.0"
# lightweight
git tag v1.0
git push --tags
git tag -d v1.o
git push origin :refs/tags/v1.0

远程仓库

  • git remote -v 查看远程仓库
  • git remote add name url 添加远程仓库
  • git push name branch -u 设为默认push仓库

.gitignore

  • #开始的行会被忽略
  • 以/开头禁止递归匹配(子目录)
  • 以/结尾表示目录
  • !取反

ssh

ssh-keygen -t rsa -C "a1173522112@163.com"
cat ~/.ssh/id_rsa.pub