How to git rebase -i for a range of commits?

帅比萌擦擦* 提交于 2019-12-04 22:19:37

You could always create a new branch with git checkout -b new_branch af39283, and then rebase that. However, if you want to include the later commits at some future point, there's no getting around rebasing them as well. The SHA1 for a commit depends on all its ancestor commits.

So, it's not entirely clear what you mean by "not including" the most recent commit, but when you do a rebase -i you're able to squash/re-order/reword/fixup/remove prior commits without having to do anything to the last commit. You're rewriting the history underneath it of course, so its diff will be re-applied and it will be a different commit object following the rebase, but since you haven't pushed this publicly (and you're rewriting the rest of it) that shouldn't matter much.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!