如何git rebase -i的一系列提交? [英] How to git rebase -i for a range of commits?

查看:143
本文介绍了如何git rebase -i的一系列提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用不包含最近提交的rebase来压缩本地特性/主题分支的一系列提交?这是针对我想在合并之前准备的提交并推送到公共回购站的提交。

Can I squash a range of commits for a local feature/topic branch using rebase that does not include the most recent commit? This is for commits that I want to prepare before they get merged and pushed to a public repo.

我很快就开始工作,并对一些较差的标题做了一些小改动,描述,我想压缩成两个或三个单独的逻辑提交与一个伟大的评论。我可以在329aed9和af39283之间选择一系列可能在此功能分支的短期历史记录中的任何提交吗?

I was working quickly and made a bunch of minor changes with poor titles and descriptions that I want to squash into two or three separate logical commits with a great comments. Can I select a range of commits between 329aed9 and af39283 that could be at any point in this feature branch's short history?

git rebase -i RANGE_START_COMMIT_ID RANGE_LAST_COMMIT_ID

感谢!

Thanks!

推荐答案

您可以使用 git checkout -b new_branch af39283 创建一个新分支,然后重新绑定它。但是,如果你想在未来的某个时间点包含后面的提交,那么也不会绕过这些提交。提交的SHA1取决于其所有的祖先提交。

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.

这篇关于如何git rebase -i的一系列提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆