そのため、ステージングされていない変更とステージングされた変更がいくつかありました。私が発行した
Welcome to Git (version 1.8.3-preview20130601)
$ git stash save --keep-index
Saved working directory and index state WIP on master: ab0d18d Setup of alarms f
or network service + Logging exceptions + long arithmetic
HEAD is now at ab0d18d Setup of alarms for network service + Logging exceptions
+ long arithmetic
$ git stash
Saved working directory and index state WIP on master: ab0d18d Setup of alarms f
or network service + Logging exceptions + long arithmetic
HEAD is now at ab0d18d Setup of alarms for network service + Logging exceptions
+ long arithmetic
次に、GUI で [amend last commit ] をクリックして、ab0d18d コミットを小さなコミットに分割しました。いくつかのファイルのステージングを解除し、ヒットしました
$ git stash save --keep-index
Saved working directory and index state WIP on master: ab0d18d Setup of alarms f
or network service + Logging exceptions + long arithmetic
HEAD is now at ab0d18d Setup of alarms for network service + Logging exceptions
+ long arithmetic
上記の手順を繰り返しました:
$ git stash save --keep-index
Saved working directory and index state WIP on master: ab0d18d Setup of alarms f
or network service + Logging exceptions + long arithmetic
HEAD is now at ab0d18d Setup of alarms for network service + Logging exceptions
+ long arithmetic
次に、コミット メッセージを編集してコミットしました。次にgit stash pop
、隠し場所を取り戻し、1つずつコミットするように発行しました。
$ git stash pop
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# TODO.txt
nothing added to commit but untracked files present (use "git add" to track)
Dropped refs/stash@{0} (43facd88ea3548071b196324523bd017d680d6dd)
災害 !
私は喜んでバックアップを持っていました(長生きするドロップボックス)
2 つの質問 :
- 私は何を間違えましたか?
- そのようなシナリオからどのように回復する必要がありますか?
EDIT:変更を復元した後のgitk(修正されたコミットはSETUP ALARMSのものです)
編集
問題を再現する方法を見つけました-修正します(おそらく最後の部分だけが必要です-元のシナリオを正確に再現しようとしていました)が、初心者向け:
mkdir test_stash; cd test_stash;git init
echo f1 >> f1 ; echo f2 >> f2 ; echo f3 >> f3 ; echo f4 >> f4 ; echo f5 >> f5
git add f1 f2 f3 f4 f5
git commit -m base123
echo change f1 to be amended >> f1
echo change f2 to be amended >> f2
echo change f3 to be amended >> f3
git add .
git commit -m tobeamended123
echo change f4 >> f4; git add f4
echo change f5 >> f5
git stash save --keep-index
git stash
git gui &
gui でamend commitを押します。どのコマンドに対応しているgit commit --amend
かはわかりませんが、うまくいきません。
修正状態にある間に、GUI でファイル f3を再度ステージング解除します(クリックして、ステージングされていない領域に移動しますgit reset HEAD f3
が、これも機能しません)。
git stash save --keep-index
git commit -m amended # not really amended - a new commit altogether
git stash pop
取得 :
# # On branch master
nothing to commit, working directory clean
Dropped refs/stash@{0} (898687d73b65ccc9e10cd826bc12fda1a4759651)
期待: f3 の変更が表示される