不,似乎沒有任何區別。
它更多地說明了git reset --soft
(即,只有搖頭,這可以have other more practical uses)
git reset HEAD
是「unstaging」,和一個簡單的git reset HEAD^
不都(移動頭部,並unstage,無需--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
這使你的狀態:
日誌後
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>
分兩步
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 --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")
謝謝您的確認。當然還有其他用途git reset --soft。 (在最基本的情況下,通常沒有理由重置索引,在這種情況下 - 軟件將節省您不得不重新設置文件的次數。)但是很好地瞭解,這兩者不需要如果你打算重置索引,那麼這個過程也是可行的。爲什麼輸入比必要的更多的字符 –
@NathanStretch我同意。這是更多的選擇(如果你正在進行一項工作,包括應該上演的進化,以及*其他*演變應該分別進行*):然後,你取消所有的任務,並且'git add'你想在你的wip中首先承諾。 – VonC