这个文档, 我们要解决每次add, commit, push的时候, 我们究竟提交了啥的问题.

目标

  1. 每次commit提交之前, 查看git的修改有哪些.
  2. 每次add之前, 查看git的修改有哪些.
  3. 每次push之前, 查看git的修改有哪些.

竟然都是diff

  1. 目前暂存中的修改:git diff –staged

  2. 尚未缓存的改动:git diff 缩写: gd

  3. 查看已缓存的改动: git diff —cached 缩写: gdca

  4. 查看已缓存的与未缓存的所有改动:git diff HEAD

  5. 显示摘要而非整个 gds:git diff –stat

  6. gdt git diff-tree –no-commit-id –name-only -r

  7. gdw git diff –word-diff

  8. 最后两次提交的差异git diff HEAD^ HEAD

  9. git diff HEAD^..HEAD
    git diff HEAD^..
    git diff HEAD^ HEAD
    git diff HEAD~15       # diff the working tree with the 15th previous commit
    git diff HEAD~15 HEAD  # diff the last commit  with the 15th previous commit
    git diff HEAD~N
    git diff HEAD~N..
    gd HEAD~2 # 这个最简洁.
    git diff @~..@
    git show
    gsps #git show --pretty=short --show-signature
    git diff @^
    git diff HEAD^
    git diff commit_id
    #这里面 ~=^, @=HEAD
    gd @^
    gd @~ #这两个都是可以的. 
    
  • [http://m.runoob.com/git/git-basic-operations.html]
  • https://github.com/ohmyzsh/ohmyzsh/wiki/Cheatsheet