打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
git combine two commit

Get back to where you started with

$ git rebase --abort

Say your history is

$ git log --pretty=onelinea931ac7c808e2471b22b5bd20f0cad046b1c5d0d cb76d157d507e819d7511132bdb5a80dd421d854f bdf239176e1a2ffac927d8b496ea00d5488481db5 a

That is, a was the first commit, then b, and finally c.

Running git rebase --interactive HEAD~2 gives you an editor with

pick b76d157 bpick a931ac7 c# Rebase df23917..a931ac7 onto df23917## 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## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#

Changing b's pick to squash will result in the error you saw, but if instead you squash c into b by changing the text to

pick b76d157 bs a931ac7 c

and save-quitting your editor, you'll get another editor whose contents are

# This is a combination of 2 commits.# The first commit's message is:b# This is the 2nd commit message:c

When you save and quit, the contents of the edited file become commit message of the new combined commit:

$ git log --pretty=oneline18fd73d3ce748f2a58d1b566c03dd9dafe0b6b4f b and cdf239176e1a2ffac927d8b496ea00d5488481db5 a
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
How to Squash Commits in Git | Learn Version Contr...
git rebase 修改以前提交的commit
git rebase 的活用
如何git squash
git merge vs rebase vs cherry-pick
Git之rebase、merge和cherry pick的区别详解—面试常问
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服