修改了文件之后

查看git的命令

  1. $ git status
  2. On branch master
  3. Changes not staged for commit:
  4. (use "git add <file>..." to update what will be committed)
  5. (use "git checkout -- <file>..." to discard changes in working directory)
  6. modified: hello.txt
  7. no changes added to commit (use "git add" and/or "git commit -a")

modified: hello.txt 的意思是你文件被修改了,这次文件的修改还没有被添加到暂存区

添加暂存区并提交代码

用git add 命令再次将文件添加到暂存区里面

  1. root@ZJJ MINGW64 /f/projectDemo (master)
  2. $ git add hello.txt
  3. warning: LF will be replaced by CRLF in hello.txt.
  4. The file will have its original line endings in your working directory
  5. root@ZJJ MINGW64 /f/projectDemo (master)
  6. $ git status
  7. On branch master
  8. Changes to be committed:
  9. (use "git reset HEAD <file>..." to unstage)
  10. modified: hello.txt
  11. root@ZJJ MINGW64 /f/projectDemo (master)
  12. $ git commit -m "第二次提交"
  13. [master e694c82] 第二次提交
  14. 1 file changed, 1 insertion(+), 1 deletion(-) # 这个意思是有一行添加了,有一行删除

1 file changed, 1 insertion(+), 1 deletion(-) # 这个意思是有一行添加了,有一行删除
为什么这么提示呢?因为git没有办法描述你这行是修改的,只能是描述成先给你这行删除,然后再给你修改之后的那行添加进去.

查看日志文件

  1. root@ZJJ MINGW64 /f/projectDemo (master)
  2. $ git reflog
  3. e694c82 (HEAD -> master) HEAD@{0}: commit: 第二次提交
  4. 7f17fee HEAD@{1}: commit (initial): 我是第一次提交

查看多了一次提交