本文介绍了重命名合并的提交而不会丢失提交的父项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
TL:DR:是否可以重命名合并(无快进合并)分支的提交 - 而不破坏历史记录?我想重命名提交。就像使用 git rebase - preserve-merges
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!
解决方案
Use git rebase with --preserve-merges
这篇关于重命名合并的提交而不会丢失提交的父项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!