Rename a merged commit without losing that commit's parents

独自空忆成欢 提交于 2020-01-15 06:55:30

问题


TL;DR: Is it possible to rename a commit from a merged (no fast forward merge) branch - without destroying history?

I want to rename a commit. Something like rebase --interactive HEAD~5. But I want to keep the HEADs in their current position. Rebase will flatten the log.

I'm using feature branches

*   c3cb3ad - Merge branch 'featureX' into develop (15 minutes ago) <FOO>
|\  
| * d945c71 - Did stuff (17 minutes ago) <FOO>
| * d4356f4 - inline commits are aweosm <FOO> (27 minutes ago) <LSC>
|/  
*   6ef9569 - bla bla bla

This is how I git:

~/dev/foo/ (develop)$ git checkout -b featureX
~/dev/foo/ (featureX)$ git add foo.html
~/dev/foo/ (featureX)$ git commit -m "inline commits are aweosm"
~/dev/foo/ (featureX)$ git checkout develop
~/dev/foo/ (develop)$ git merge --no-ff featureX
~/dev/foo/ (develop)$ git branch -D featureX
~/dev/foo/ (develop)$ git add bar.html
~/dev/foo/ (develop)$ git commit -m "Lorem Ipsum"

... oh crap. There's a typo in my commit message!


回答1:


Use git rebase with --preserve-merges



来源:https://stackoverflow.com/questions/30863227/rename-a-merged-commit-without-losing-that-commits-parents

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!