Git使用rebase重新排序提交无法正常工作?

时间:2015-07-27 07:25:23

标签: git git-rebase

我正在尝试重新排序我最近的两次提交。

我订购了

449b581 latest commit 
8aa0c5a commit prior to latest commit

我已经使用comand

加入了rebase
git rebase -i HEAD~2

带我到带有文字的VIM编辑器

pick 8aa0c5a commit prior to latest commit
pick 449b581 latest commit

# Rebase a716b77..449b581 onto a716b77
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

交换提交后

pick 449b581 latest commit
pick 8aa0c5a commit prior to latest commit

退出VIM我得

$ git rebase -i HEAD~2
Successfully rebased and updated refs/heads/master.

但我的日志仍然相同。怎么会?在看到第一次没有按预期进行后,我尝试了不同的选择命令顺序。 ;) 没有错误,没有合并待处理或类似的东西。在重新提交提交之前,我不得不存储几个文件。它影响了变基吗?

不过,我想做的就是将我的最后一次提交推送到远程存储库,但我也不希望之前的提交也在那里。我是在正确的轨道上还是我可以在不重新订购提交的情况下实现这一目标?

1 个答案:

答案 0 :(得分:2)

你在退出vim之前保存了文件吗?您可能只是退出而没有保存,因此更改将丢失并且提交顺序将是相同的。因此,在变基之后没有变化。

相关问题