git

  • It is good practice to always review our changes before saving them. We do this using git diff. This shows us the differences between the current state of the file and the most recently saved version:
git diff
  • Git does not track directories on their own, only files within them.
  • See the differences between older commits we can use git diff
# 最近commit和当前的区别
git diff HEAD

# 最近commit的往前一次的commit和当前的区别
git diff HEAD~1 mars.txt

# 最近commit的往前两次次的commit和当前的区别
git diff HEAD~2 mars.txt
  • shows us what changes we made at an older commit as well as the commit message, rather than the differences between a commit and our working directory
# 最近commit做了哪些事
git show HEAD
  • We can also refer to commits using those long strings of digits and letters that git log displays
git diff f22b25e3233b4645dabd0d81e651fe074bd8e73b mars.txt
# 其实用前几位就够了
git diff f22b25e mars.txt
  • restore older versions of things
# 假设只是修改了文件 没有add 没有commit
# 测试了一下 发现add之后也可以restore
git status


# 将文件返回到最近一次commit 当然也可以通过别的HEAD或者log里的ID来返回更靠前的commit
# 不要忘记文件名 不然整个都会被restore
git checkout HEAD mars.txt

http://swcarpentry.github.io/git-novice/

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。