How do I change a commit message after a 'git-pull' auto-merge?

最后都变了- 提交于 2019-12-05 02:39:48

问题


Occasionally, my collaborators will "panic" when there is an automatic merge generated as the result a git-pull, and just accept the default commit message. Before this commit gets pushed, I want to be sure the message gets fixed, but --amend seems not to work. What is the best way to fix the message that's generated in this scenario. The best instructions I can come up with for them are

git reset --soft HEAD~
git merge -m <message> <the tracked remote branch>

but that seems a bit scary (reset) and error prone (the remote tracked branch has to be entered explicitly).

Is there a simple way to change the commit message that was just generated by merging with a remote tracking repo? Why doesn't --amend work?


回答1:


git commit --amend should work in this scenario. What exactly does not work?




回答2:


You can always try using git pull --rebase in order to put your commits on top of the tree. But git warns against this saying.

"This is a potentially dangerous mode of operation. It rewrites history, which does not bode well when you published that history already. Do not use this option unless you have read git-rebase(1) carefully." (http://git-scm.com/docs/git-pull)

If you are fine with eliminating the history of the merge then this is the option for you.




回答3:


@{u} is a good replacement for your <the tracked remote branch>, and then you can just glue the two steps into one. Perhaps a shell script you can distribute to them, or an alias they can add to their shells.



来源:https://stackoverflow.com/questions/14573794/how-do-i-change-a-commit-message-after-a-git-pull-auto-merge

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