不,似乎没有任何区别。
更多的是说明git reset --soft
(即仅移动HEAD,它可以有其他更实际的用途)
git reset HEAD
用于“取消暂存”,并且git reset HEAD^
两者都简单(移动 HEAD 和取消暂存,不需要--mixed
,因为它是默认选项)
这是一个快速测试,看看它是什么样子的:
之前(您只需切换回功能,在那里您提交了一个“ wip
”——正在进行中的工作):
C:\Users\VonC\prog\git\test\r\r3>gl
* 6ac95bd - (origin/master, origin/HEAD, master) fix in master (2 minutes ago) <VonC>
| * fd8d97d - (HEAD, origin/feature, feature) snap WIP (3 minutes ago) <VonC>
| * 16066dd - f1 (3 minutes ago) <VonC>
|/
* e8ad96f - f1 (3 minutes ago) <VonC>
重置本身:
C:\Users\VonC\prog\git\test\r\r3>git reset "HEAD^"
Unstaged changes after reset:
M f
这给了你状态:
C:\Users\VonC\prog\git\test\r\r3>git st
# On branch feature
# Your branch is behind 'origin/feature' by 1 commit, and can be fast-forwarded.
# (use "git pull" to update your local branch)
#
# 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: f
#
no changes added to commit (use "git add" and/or "git commit -a")
登录后git reset HEAD^
C:\Users\VonC\prog\git\test\r\r3>gl
* 6ac95bd - (origin/master, origin/HEAD, master) fix in master (6 minutes ago) <VonC>
| * fd8d97d - (origin/feature) snap WIP (7 minutes ago) <VonC>
| * 16066dd - (HEAD, feature) f1 (7 minutes ago) <VonC>
|/
* e8ad96f - f1 (8 minutes ago) <VonC>
在两个步骤中,您将在 之后看到以下日志git reset --soft HEAD^
:
C:\Users\VonC\prog\git\test\r\r2>gl
* 6ac95bd - (origin/master, origin/HEAD, master) fix in master (65 seconds ago) <VonC>
| * fd8d97d - (origin/feature) snap WIP (89 seconds ago) <VonC>
| * 16066dd - (HEAD, feature) f1 (2 minutes ago) <VonC>
|/
* e8ad96f - f1 (2 minutes ago) <VonC>
您的索引仍将反映上演的内容wip
:
C:\Users\VonC\prog\git\test\r\r2>git st
# On branch feature
# Your branch is behind 'origin/feature' by 1 commit, and can be fast-forwarded.
# (use "git pull" to update your local branch)
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: f
#
然后重置将取消分阶段,使您回到与git reset HEAD^
一步相同的阶段:
C:\Users\VonC\prog\git\test\r\r2>git reset
Unstaged changes after reset:
M f
C:\Users\VonC\prog\git\test\r\r2>git st
# On branch feature
# Your branch is behind 'origin/feature' by 1 commit, and can be fast-forwarded.
# (use "git pull" to update your local branch)
#
# 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: f
#
no changes added to commit (use "git add" and/or "git commit -a")