git 本地操作(三、查看对比历史记录)

Posted on Posted in git
Tips: 本文创建于2016年5月11日,已超过 2 年,内容或图片可能已经失效!
  • git show
  • git log
  • git diff
-> liuhonghe@support ~/git/git_repo git:(master) ☺ git log --oneline --decorate --graph --all  
*   6d4653b (HEAD, master) merge  
|\    
| * df641d6 (test) Initial commit on test  
* | 8bb97f0 (test_merge) Initial commit on test_merge  
* | 78cd3a1 Initial commit on test_merge  
* | 19070c8 Initial commit on test_mergi  
|/    
* e93b143 Second commit on master  
| *   5b37bf7 (refs/stash) WIP on fix_v0: f699140 Initial commit on master  
| |\    
|/ /    
| * ae71b98 index on fix_v0: f699140 Initial commit on master  
|/    
* f699140 (v0, tag: INITIAL_COMMIT, fix_v0) Initial commit on master  
-> liuhonghe@support ~/git/git_repo git:(master) ☺ git show df641d6 #或者 git show master 或 git show HEAD  
-> liuhonghe@support ~/git/git_repo git:(master) ☺ git show master^ # git show master^2    git show master~  
  
-> liuhonghe@support ~/git/git_repo git:(master) ☺ git show --stat master^2 # 查看改变的信息  
commit df641d6f03bef7e708c08b4f8d301486f56dee82  
Author: liuhonghe <liuhonghe@iZ25trmqls5Z.(none)>  
Date:   Wed May 11 14:12:34 2016 +0800  
  
    Initial commit on test  
-> liuhonghe@support ~/git/git_repo git:(master) ☺ git log -p   #每一个commit之间的差异信息  
-> liuhonghe@support ~/git/git_repo git:(master) ☺ git log --stat   #统计信息  
-> liuhonghe@support ~/git/git_repo git:(master) ☺ git log --oneline    #单行信息  
  
  
 master.txt |    1 +  
 1 files changed, 1 insertions(+), 0 deletions(-)  
-> liuhonghe@support ~/git/git_repo git:(master) ☺ echo "git diff" >> master.txt  
-> liuhonghe@support ~/git/git_repo git:(master) ☺ git diff  
diff --git a/master.txt b/master.txt  
index 1848ad2..6349668 100644  
--- a/master.txt  
+++ b/master.txt  
@@ -1,3 +1,4 @@  
 Initial commit  
 Second commit on master  
 Initial commit on test_merge  
+git diff  
-> liuhonghe@support ~/git/git_repo git:(master) ✗ ☺ git add master.txt   
-> liuhonghe@support ~/git/git_repo git:(master) ✗ ☺ git diff #add后diff为空  
-> liuhonghe@support ~/git/git_repo git:(master) ✗ ☺ git diff --cached  
diff --git a/master.txt b/master.txt  
index 1848ad2..6349668 100644  
--- a/master.txt  
+++ b/master.txt  
@@ -1,3 +1,4 @@  
 Initial commit  
 Second commit on master  
 Initial commit on test_merge  
+git diff  
-> liuhonghe@support ~/git/git_repo git:(master) ✗ ☺ git diff HEAD HEAD~2  
-> liuhonghe@support ~/git/git_repo git:(master) ✗ ☺ git diff HEAD HEAD~2 -- master.txt  
-> liuhonghe@support ~/git/git_repo git:(master) ✗ ☺ git diff --color-words  

Leave a Reply

Your email address will not be published. Required fields are marked *

1 + eight =