git - git rebase -i HEAD~2 的问题
问题描述
这是我的 git 日志:
$ git log --oneline
0729a5e (HEAD -> feature/fork_deploy_function) merge with gitlab
0a6421d implement aws kubernetes deploy phase1
bde4da0 (origin/feature/fork_deploy_function) partially implement kubenetes deployment
bde4da0
是 gitlab 中的最新版本,我做了一个 local commit0a6421d
和一个 pull and merge branch commit 0729a5e
。现在,在我将本地提交推送到 gitlab 之前,我想使用 压缩最后两个提交0729a5e
和0a6421d
一个提交,令人惊讶的git rebase -i HEAD~2
是,当我运行它时,我得到了提交bde4da0
,并且0a6421d
在编辑器中而不是0729a5e
and 0a6421d
。见下文:
pick 0a6421d implement aws kubernetes deploy phase1
pick bde4da0 partially implement kubenetes deployment
怎么会这样?在这种情况下如何压缩前两个提交?谢谢
解决方案
不知道为什么,但这不应该失败:
git checkout 0729a5e
git reset --soft bde4da0
# all changes introduced by the last two revisions will be in index, ready to be committed
git commit -m "squash"
# if you like the result
git branch -f feature/fork_deploy_function
推荐阅读
- python - 使用 Boto3 的 AWS SNS 消息格式
- c# - 从表中检索所有项目,其中表列的文本包含在项目列表中(ASP.NET Core 2.2 C# LINQ)
- github - 为什么一些 Github 拉取请求批准复选标记有不同的颜色(绿色、灰色)?
- python - 告诉 Flask-Migrate / Alembic 不要删除它不知道的任何表
- object - Kotlin 中嵌套对象声明的可访问性不一致
- javascript - 更改键上的值
- javascript - 即使 console.log 给出正确的结果,整体功能也不会运行
- python-3.x - python:用null解码字节;null 仍然显示中间字符串
- java - 充气城堡和 WebPush:NoSuchMethodError:org.bouncycastle.math.ec.ECCurve$Fp
- vba - MAPI Schema 或 URN Schema 等价于查找 mailitem.ConversationID()