search

Home  >  Q&A  >  body text

Git 的 commit message 写错了,有办法进行修改么?

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

PHPzPHPz2875 days ago1314

reply all(8)I'll reply

  • ringa_lee

    ringa_lee2017-04-27 09:05:08

    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

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-04-27 09:05:08

    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.

    reply
    0
  • 滿天的星座

    滿天的星座2017-04-27 09:05:08

    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~

    reply
    0
  • 高洛峰

    高洛峰2017-04-27 09:05:08

    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. . .

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-04-27 09:05:08

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

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-27 09:05:08

    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.

    reply
    0
  • 迷茫

    迷茫2017-04-27 09:05:08

    git commit --amend

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-04-27 09:05:08

    The question is already well answered on stack overflow :)

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

    reply
    0
  • Cancelreply