标签:zed repos nbsp not res 假设 mode osi cond
--mix,--hard,--soft
针对每个选项都是操作这个文件。
[root@centos demo]# git init Initialized empty Git repository in /root/demo/.git/ [root@centos demo]# echo one >> a.txt [root@centos demo]# git add a.txt [root@centos demo]# git commit -m "first commit" [master (root-commit) b7ee3a2] first commit 1 file changed, 1 insertion(+) create mode 100644 a.txt [root@centos demo]# echo two >> a.txt [root@centos demo]# git commit -am "second commit" [master 92ae9c4] second commit 1 file changed, 1 insertion(+) [root@centos demo]# echo three >> a.txt [root@centos demo]# git commit -am "third commit" [master 0985eec] third commit 1 file changed, 1 insertion(+) [root@centos demo]# echo four >> a.txt [root@centos demo]# git commit -am "four commit" [master 5bd480c] four commit 1 file changed, 1 insertion(+) [root@centos demo]# git show-branch --more=4 #查看四次提交记录 [master] four commit [master^] third commit [master~2] second commit [master~3] first commit
在省略reset选项的时候,默认的就是使用--mix
[root@centos demo]# git reset HEAD~2
Unstaged changes after reset:
M a.txt
[root@centos demo]# 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@centos demo]# cat a.txt
one
two
three
four
[root@centos demo]# git diff
diff --git a/a.txt b/a.txt
index 69f75fc..a4c0ca1 100644
--- a/a.txt
+++ b/a.txt
@@ -1,2 +1,4 @@
one
two
+three
+four
从运行结果可以看出来,--mix有以下特点:

假设使用reset命令从版本D回到版本B,那么HEAD就会指向B。同时,从版本B到版本D之间做的文件修改并不会丢失,会保留版本D相对于B的diff。
标签:zed repos nbsp not res 假设 mode osi cond
原文地址:https://www.cnblogs.com/-beyond/p/9495971.html