#1.改变了工作目录中的文件,没有添加到暂存区
[root@git ~/git_test]# echo "222222222" >>a.txt
[root@git ~/git_test]# cat a.txt
111111111
222222222
[root@git ~/git_test]# git diff .
diff --git a/a.txt b/a.txt
index bb81b3c..61eb21a 100644
--- a/a.txt
+++ b/a.txt
@@ -1 +1,2 @@
111111111
+222222222
[root@git ~/git_test]# 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: a.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
#将暂存区文件的内容恢复到工作目录中
[root@git ~/git_test]# git checkout -- . #覆盖所有
[root@git ~/git_test]# git checkout -- a.txt #覆盖某个文件
[root@git ~/git_test]# git status
# On branch master
nothing to commit, working directory clean
[root@git ~/git_test]# git diff .
[root@git ~/git_test]# cat a.txt
11111111
Git恢复数据
最新推荐文章于 2024-05-21 19:00:08 发布