Nie, nie ma żadnej różnicy.
Jest to bardziej ilustrujące git reset --soft
(tj.przesuwając główka, która może have other more practical uses)
git reset HEAD
jest dla „unstaging” i prosty git reset HEAD^
ma zarówno (przesunąć głowę i unstage, nie ma potrzeby --mixed
, ponieważ jest to opcja domyślna)
Oto szybki test, aby zobaczyć, co to wygląda:
Przed (po prostu powrócić do funkcji, której dopuściła się „wip
” - praca w toku):
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>
Reset sama:
C:\Users\VonC\prog\git\test\r\r3>git reset "HEAD^"
Unstaged changes after reset:
M f
To daje status:
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")
dziennika po 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>
w dwóch etapach, byś widział następujący dziennik po git reset --soft HEAD^
:
Indeks
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>
Ty nadal odzwierciedlają to, co wystawiono na 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
#
Reset będzie wtedy Unstaged, przynosząc z powrotem do tego samego etapu niż git reset HEAD^
musiałby w jednym kroku:
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")
Dzięki za potwierdzenie. I na pewno istnieją inne zastosowania do resetowania git --soft. (W najbardziej podstawowym przypadku, często nie ma po prostu powodu, aby zresetować indeks, w takim przypadku --soft zaoszczędzi ci konieczności ponownego przygotowania plików.) Ale dobrze wiedzieć na pewno, że nie ma potrzeby, aby te dwa -stage procesu, jeśli i tak planujesz zresetować indeks. Po co wpisywać więcej znaków niż jest to konieczne? –
@NathanStretch Zgadzam się. Bardziej jest dać wybór (na wypadek, gdybyś popełnił dzieło w toku składające się z ewolucji, które powinny być wystawiane, i * inne * ewolucje, które powinny być wystawiane * oddzielnie *: wtedy wszystko rozpakowujesz i 'git add' co ty chcesz najpierw popełnić w swoim wycierku. – VonC