在将分支与冲突合并后,git自动生成提交消息,如下所示:
合并分支{分支}到{分支名称}
Remote repo,我目前正在使用got提交消息验证,并且只传递特定模板的消息。如果像以前一样使用提交消息推送一个分支,它就会被拒绝,因为它与模板不匹配。Intellij只允许重述由我编写的提交,并且调用git重基-i HEAD~3并不能在打开的编辑器中显示提交。
如果有一种方法来重命名/更改提交消息?谢谢。
发布于 2020-04-09 17:08:21
试试git rebase -p -i HEAD~3。
手册页上写着:
-p, --preserve-merges
Recreate merge commits instead of flattening the history by
replaying commits a merge commit introduces. Merge conflict
resolutions or manual amendments to merge commits are not
preserved.
This uses the --interactive machinery internally, but combining it
with the --interactive option explicitly is generally not a good
idea unless you know what you are doing (see BUGS below).不过你应该没事的。BUGS部分内容如下:
... Editing commits and rewording their commit messages should work fine,
but attempts to reorder commits tend to produce counterintuitive results. 例如(下面的git hist是git log的别名,有几个选项可以很好地显示):
atsaloli@Aleksey_X1_C2G:~/git/stackoverflow-61125266$ git hist
* ecbdcc5 2020-04-09 | Add pineapple (HEAD) [Aleksey Tsalolikhin]
* f9353df 2020-04-09 | Merge branch 'mybranch' into HEAD [Aleksey Tsalolikhin]
|\
| * aadd990 2020-04-09 | add cherry (mybranch, master) [Aleksey Tsalolikhin]
|/
* 166d386 2020-04-09 | Add pear to fruit list [Aleksey Tsalolikhin]
* 6a64ac2 2020-04-09 | Add bnana to fruit list [Aleksey Tsalolikhin]
* f42522f 2020-04-09 | Initialize fruit list [Aleksey Tsalolikhin]
atsaloli@Aleksey_X1_C2G:~/git/stackoverflow-61125266$ 和:
atsaloli@Aleksey_X1_C2G:~/git/stackoverflow-61125266$ git rebase -p -i HEAD~4
...
pick 6a64ac2 Add bnana to fruit list
pick 166d386 Add pear to fruit list
pick aadd990 add cherry
pick f9353df Merge branch 'mybranch' into HEAD
pick ecbdcc5 Add pineapple现在我可以编辑合并提交消息了。
顺便说一句,这个问题似乎是Git: How to edit/reword a merge commit's message?的翻版
发布于 2020-04-09 16:02:06
您尝试过git commit --amend吗?这应该允许您在上次提交时修改消息。
发布于 2020-04-09 16:07:34
默认情况下,git rebase -i不包括合并提交。它试图智能地创建一个线性历史,而不是复制合并。
要编辑提交消息,可以运行git commit --amend,这将允许您在默认文本编辑器中编辑消息,或者允许git commit --amend -m "Write your message here"将消息直接写入命令行。
https://stackoverflow.com/questions/61125266
复制相似问题