(master) $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: deleteme # renamed: same -> renamed # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: changed # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # addme
(master) apple[example] $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: three # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: three #
你可以使用 git diff 来显示这两个文件之间的差异:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
(master) $ git diff diff --git a/three b/three index bb87574..3179466 100644 --- a/three +++ b/three @@ -1 +1 @@ -This is the version in the index +This is the version in the working tree (master) $ git diff --cached diff --git a/three b/three index 48d0444..bb87574 100644 --- a/three +++ b/three @@ -1 +1 @@ -This is the previously committed version +This is the version in the index
(master) $ git show 48d0444 This is the previously committed version (master) $ git show bb87574 This is the version in the index (master) $ cat three This is the version in the working tree