git - 更新未显示在 git merge 中的合并提交消息
问题描述
我有以下提交,我需要使用分支名称更新中间提交。
...
...
9a3de7d [#US810469]Add configuration
807fed0 Merge branch 'master' of github.xx.com:org/repo
6153e1e [#US810469] fix typo
我意识到当我git rebase -i
没有显示合并提交时,我知道了为什么在这里[合并提交没有出现在 git rebase --interactive
在交互式外壳中,我看到它说如果您删除一行,您将丢失提交。我想也许我可以在我想要的地方添加一个提交:) 但这没有用。它不断向我显示要编辑的待办事项。我尝试编辑它们并再次提交,但每次都失败。
如何将中间提交的消息更改为“[#US810469]Merge branch 'master' of github.xx.com:org/repo”?
解决方案
当你git rebase -i
,你正在以线性方式重写历史,从而删除你的合并提交。你可以这样做(假设你在开发分支上)
git branch temp # create temporary branch where you are now (at 6153e1e I suppose)
git reset --hard 807fed0 # move develop branch to the merge commit
git commit --amend # now edit your message to look the way you want it
git cherry-pick temp # since there is only commit in temp branch, cherry-pick will do
如果您在合并提交后有多个提交,那么您可以:
git checkout temp
git rebase develop
git checkout develop
git rebase temp
git branch -d temp
可能有一些捷径,但这样我很容易理解这些步骤;希望你也...
推荐阅读
- git - 本地合并分支无法解决 github 上的拉取请求
- apache-spark - Spark Streaming 批处理持续时间
- mysql - Mysql2::Error: Data too long for column 'object' at row 1 尝试使用 Active Record 更新时出错
- reactjs - Firebase消息传递和ReactJS,当网站在前台时,未收到推送通知
- python - Python中的列表切片与索引?
- mysql - MySQL错误即使清除和重新安装也不能解决它
- node.js - 所有测试都通过时测试套件失败:Jest & Supertest with GraphQL request
- java - 带有 apache POI 的验证字符串
- sql - 如何根据 WHERE 子句替换 Teradata 表中字段(列)中的所有值?
- python - 添加到数据框的列不显示标题值