3
假设这样的:如何在同一个提交的rebase之后恢复合并提交?
mkdir test; cd test
echo "1" > file1; git init; git add .; git commit -m "initial - file 1" # 1st commit on master
echo "2" > file2; git add .; git commit -m "file 2" # 2nd commit on master
git checkout -b newbranch # creates newbranch
echo "1" >> file1; git add .; git commit -m "changed 1" # 1st commit on newbranch
git checkout master # goes to master
echo "2" >> file2; git add .; git commit -m "changed 2" # 3rd commit on master
git merge newbranch -m "merge commit" # merge newbranch on master
echo "3" > file3; git add .; git commit --amend -m "merge commit" # amend merge commit and adds file3
git rebase HEAD~2 # don't change anything, just leave
ls # there isn't file3 anymore!
有没有办法恢复合并提交,以便进行修改就可以了,这些变化不会丢失?
Thx,但'git reflog'上的任何提交都显示'file3'。在所有提交中'git whatchanged'。 – bitlogic
@bitlogic再次检查。运行你的上面的脚本,然后是'checkout HEAD @ {4}',恢复'file3'。 – Borealid
是的,这是正确的。在那。奇怪的是,'git whatchanged'不显示文件被添加! – bitlogic