测试目的:
git 本地仓库测试git status -s 、git diff 等命令
测试流程:
对于已提交的文件更改两行内容。利用git status -s、git diff 命令观察返回信息,git add 后 重复上面两个命令观察返回信息
$ git diff
diff --git a/git-test.txt b/git-test.txt
index 7787faa..d2f948d 100644
--- a/git-test.txt
+++ b/git-test.txt
@@ -1,2 +1,3 @@
111
-222
\ No newline at end of file
+222
+333
\ No newline at end of file
vastSky@DESKTOP-212DM6S MINGW64 /e/git-test (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: git-test.txt
no changes added to commit (use "git add" and/or "git commit -a")
vastSky@DESKTOP-212DM6S MINGW64 /e/git-test (master)
$ git status -s
M git-test.txt
vastSky@DESKTOP-212DM6S MINGW64 /e/git-test (master)
$ git add git-test.txt
vastSky@DESKTOP-212DM6S MINGW64 /e/git-test (master)
$ git status -s
M git-test.txt
vastSky@DESKTOP-212DM6S MINGW64 /e/git-test (master)
$ git diff
工作区暂存区文件不一致,通过git diff 可以展示
得出结论:
git status -s 会用不同颜色表示文件状态(红色M在工作区中修改未add,绿色M在工作区中修改后在缓存区中等待提交)git diff 比较的为缓存区与工作区中文件的不同。如果缓存区中没有文件则为.git仓库中与工作区文件中的不同
git diff 工作区与缓存区的不同
git diff -cached 缓存区与版本库的不同 = git commit -v