Git 的 commit message 写错了,有办法进行修改么?
PHPz
PHPz 2017-04-27 09:03:08
0
8
1274

如题,有时候拼音输入法输错,导致提交了些少儿不宜的单词。
测试 mm 看了不好,请问怎么修改提交的消息呢?

PHPz
PHPz

学习是最好的投资!

reply all(8)
左手右手慢动作

git commit --amend You can make changes to the last submission

push -f If the last submission has been pushed, you need to add the f parameter to cover the server, but this is not recommended

我想大声告诉你

If it has been submitted through git push, it depends on what git server your company uses. Generally, if users want to modify it, they need relevant permissions and contact the administrator; if other developers have modified and submitted it based on your submission, That would be even more troublesome, as all subsequent submissions would have to be done again;
If it has not been pushed to the server, but the commit has been made locally, and no new commit has been made, just git commit --amend;如果进行了新的commit,只需要git reset --soft xxx (xxx有问题那次提交的commit id),然后在进行git commit will do, but all subsequent submissions will become one submission; if you want to keep each submission independent, use

git checkout -b tmp ^xxx
git cherry-pick xxx
git commit --amend
git cherry-pick <依次后面的提交id>

xxx still has a problem with the commit id of that submission. Create a separate tmp branch modification description, then cherry-pick the subsequent submissions one by one to the new branch, and then delete the old branch.

滿天的星座

Although this question has been in the past for a long time, I still want to add one more:
If you want to modify the author of previous commits, here is a script you can use: link~

小葫芦

git commit --amend or you can use git reset HARD to cancel the last commit and then try again.
But since it has already been pushed, I don’t know how to do it. . .

淡淡烟草味

git commit --amend
Do you have a code review system? Similar to Gerrit? This kind of thing can be submitted multiple times before submitting

大家讲道理

git commit --amend

Note:
I tested it and found that in the gerrit environment, just using git commit --amend to modify the commit message will fail to submit.
Change the code, such as adding a blank line, and then git add and git commit --amend to submit it.

迷茫

git commit --amend

仅有的幸福

The question is already well answered on stack overflow :)

http://stackoverflow.com/questions/179123/edit-an-incorrect-commit-message-in-git

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template