Git 提交压缩(rebase -i):提交实际上是如何工作的?
我不太明白提交是如何用 git rebase -i 压缩的。我想知道一件事:
如果我的 rebase -i 生成这个列表:
pick A Last commit
pick B Commit
pick C Some other commit
我应该压缩提交 A 和 B 还是 B 和 C?问题是 git 在这种情况下表示它将把 D..A 重新设置为 D(D 是在此之前的最后一次提交),而不是将 C..A 重新设置为 C,这对我来说是有意义的。 D 根本没有显示,那为什么要这样说呢?
I don't quite understand how the commits are squashed with git rebase -i. There is one thing I was left wondering:
If my rebase -i produces this list:
pick A Last commit
pick B Commit
pick C Some other commit
Should I squash commits A and B or B and C? Problem is git said in this case that it would rebase D..A onto D (D being the last commit before this) rather than C..A onto C which would make sense to me. D is not shown at all, so why word it like that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是 git 术语中的
D..A
意思是“从 D 到 A 不包括 D 本身”。如果你查看 git-rev-list 手册页,你会看到意思是“列出
中包含但未包含在
中的所有提交以及所做的更改。 byD
本身包含在D
commit 中,因此它不包含在表示为D..A
的列表中。正确的说法是
git rebase -i D
影响D..HEAD
。The thing is that
D..A
in git terminology means "from D to A not including D itself". If you look intogit-rev-list
manual page, you'll see thatwhich means "list all commits that are included in
<commit2>
, but are not included in<commit1>
. And the changes made byD
itself are included inD
commit. So it's not included in list denoted asD..A
.That's why it's correct to say that
git rebase -i D
affectsD..HEAD
.