No, non sembra esserci alcuna differenza.
È più per illustrare il git reset --soft
(vale a direspostandosi solo HEAD, che può have other more practical uses)
git reset HEAD
è per "unstaging", e una semplice git reset HEAD^
fa entrambe (muovere la testa, e unstage, senza bisogno di --mixed
, poiché è l'opzione di default)
ecco un breve test per vedere che cosa assomiglia:
Prima (basta passare di nuovo a funzione, dove commesso un "wip
" - lavori in corso):
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>
Il reset stesso:
C:\Users\VonC\prog\git\test\r\r3>git reset "HEAD^"
Unstaged changes after reset:
M f
Che ti dà lo stato:
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")
log dopo 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>
in due fasi, che avrebbe visto la seguente registro dopo lo git reset --soft HEAD^
:
indice
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>
si sarebbe ancora riflettere ciò che è stato messo in scena per la 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
#
Il reset sarebbe poi Unstaged, riportandovi stesso palco di un git reset HEAD^
avrebbe in un solo passaggio:
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")
Grazie per la conferma. E certamente ci sono altri usi per git reset - soft. (Nel caso più semplice, spesso non c'è semplicemente alcun motivo per reimpostare l'indice, nel qual caso --soft ti farà risparmiare la necessità di riposizionare i file.) Ma buono a sapersi per certo che non è necessario per i due -stage process se hai intenzione di resettare l'indice in ogni caso. Perché digitare più caratteri del necessario? –
@NathanStretch Sono d'accordo. È più di dare una scelta (nel caso in cui hai impegnato un work in progress composto da evoluzioni che dovrebbero essere messe in scena, e * altre * evoluzioni che dovrebbero essere messe in scena * separatamente *: poi, togli tutto e aggiungi git add what you you vuoi impegnarti per primo nel tuo wip. – VonC