修改的文件不能直接提交,下面是自己做的实验:
前提:a.txt 文件已经被git管理——已经提交了
1、修改a.txt文件,在最后面添加一行内容
$ echo "Nice to meet you" >> a.txt
2、 提交修改内容
$ git commit -m "no modify commit"
上面提示提交不成功 (
需要对修改的a.txt文件执行 git add 命令
)
3、将a.txt文件添加到暂存区中
$ git add a.txt
4、继续修改a.txt文件,在最后一行添加内容
$ echo "see you" >> a.txt
5、提交修改的文件
$ git commit -m "second commit file"
6、使用git checkout a.txt命令查看恢复到已经提交的状态