之前的文章(git创建版本库)已经添加并提交了一个readme.txt文件
- 现在我们继续工作,修改一下readme.txt文件内容
- 然后运行git status 看看结果
$ git status
On branch master
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: readme.txt
no changes added to commit (use "git add" and/or "git commit -a")
git status 命令可以让我们时刻掌握仓库当前的状态,上面的命令输出告诉我们,readme.txt被修改过了,但还没有准备提交的修改
- git diff查看修改的内容
lvjingying@LAPTOP-VGTK7EP5 MINGW64 /e/githome/learngit (master)
$ git diff
diff --git a/readme.txt b/readme.txt
index 7abd34b..3ba3ac2 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,2 @@
Git is one
-Git is two
\ No newline at end of file
+Git is two 改动
\ No newline at end of file
从上面的输出可以看到,我们在第二行添加了“改动”汉字
- 知道了有什么改动之后。提交就放心多了。git add
lvjingying@LAPTOP-VGTK7EP5 MINGW64 /e/githome/learngit (master)
$ git add readme.txt
- 在git commit之前我们在看看状态
lvjingying@LAPTOP-VGTK7EP5 MINGW64 /e/githome/learngit (master)
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: readme.txt
git status告诉我们,将要被提交的修改包括readme.txt下面可以放心的提交了
lvjingying@LAPTOP-VGTK7EP5 MINGW64 /e/githome/learngit (master)
$ git commit -m "修改了第二行加了中文改动"
[master 376ad95] 修改了第二行加了中文改动
1 file changed, 1 insertion(+), 1 deletion(-)
- 再看看仓库状态
lvjingying@LAPTOP-VGTK7EP5 MINGW64 /e/githome/learngit (master)
$ git status
On branch master
nothing to commit, working tree clean
Git告诉我们当前没有需要提交的修改