所以我有一些非分阶段的变化和一些上演的变化。我发了
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 中的最后一次提交,将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
来开始取回我的藏匿处并逐一提交它们。
$ 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)
灾难!
我快乐地备份了(万维活跃的dropbox)
2个问题:
编辑:我恢复更改后的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中的提交 。不确定它对应哪个命令,但git commit --amend
不能解决问题。
在处于修改状态的非舞台文件f3 再次在gui (点击它以便它在未分段区域移动 - 将是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修改显示