发布于 2014-04-23 20:36:07
我发现一个相当简单的解决方案是使用git-重基的交互式重基模式重新排序提交。在调用git rebase -i HEAD~3以重新定位HEAD之前的最近三次提交时,会出现(我自己的注释用#注释):
pick 57c3e7e [bug 972919] Removed outdated information from the readme
pick 9390105 [bug 972919] Cleaned up app.js
pick 626e865 [bug 972919] Removed CORS logic
# Git provides standard instructions for the use of this mode in comments
# below the commits you've selected通过将我想要的提交行移到列表的末尾,它将其重新排序为在完成重基时历史上最近的一次:
pick 9390105 [bug 972919] Cleaned up app.js
pick 626e865 [bug 972919] Removed CORS logic
pick 57c3e7e [bug 972919] Removed outdated information from the readme # <-- this one will be most recent发布于 2014-04-23 16:08:18
git rebase -i HEAD~NumberOfCommits,其中NumberOfCommits是要检查的提交量。
Git将使用提交列表打开编辑器,您可以在其中选择编辑、压缩或跳过任何提交。如果要删除提交,则删除行:
# 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.请注意,当您这样做时,您的分支将与远程不同,因此您将不得不强行推送,如果其他人有旧历史的副本,则需要对新历史进行硬重置。
请阅读重设基地的危险分章。它得到了一个比我能提供的更好的解释。
https://stackoverflow.com/questions/23249430
复制相似问题