修改了文件之后
查看git的命令
$ 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: hello.txt
no changes added to commit (use "git add" and/or "git commit -a")
modified: hello.txt 的意思是你文件被修改了,这次文件的修改还没有被添加到暂存区
添加暂存区并提交代码
用git add 命令再次将文件添加到暂存区里面
root@ZJJ MINGW64 /f/projectDemo (master)
$ git add hello.txt
warning: LF will be replaced by CRLF in hello.txt.
The file will have its original line endings in your working directory
root@ZJJ MINGW64 /f/projectDemo (master)
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: hello.txt
root@ZJJ MINGW64 /f/projectDemo (master)
$ git commit -m "第二次提交"
[master e694c82] 第二次提交
1 file changed, 1 insertion(+), 1 deletion(-) # 这个意思是有一行添加了,有一行删除
1 file changed, 1 insertion(+), 1 deletion(-) # 这个意思是有一行添加了,有一行删除
为什么这么提示呢?因为git没有办法描述你这行是修改的,只能是描述成先给你这行删除,然后再给你修改之后的那行添加进去.
查看日志文件
root@ZJJ MINGW64 /f/projectDemo (master)
$ git reflog
e694c82 (HEAD -> master) HEAD@{0}: commit: 第二次提交
7f17fee HEAD@{1}: commit (initial): 我是第一次提交
查看多了一次提交