Editing the git commit message in GitHub

后端 未结 7 808
臣服心动
臣服心动 2020-12-07 09:25

Is there any way of online editing the commit message in GitHub.com, after submission?

From the command line, one can do

git commit --am         


        
相关标签:
7条回答
  • 2020-12-07 09:38

    You need to git push -f assuming that nobody has pulled the other commit before. Beware, you're changing history.

    0 讨论(0)
  • 2020-12-07 09:41

    I was facing the same problem.

    See in your github for a particular branch and you will come to know the commit id of the very first commit in that branch. do a rebase to that:

    git rebase -i

    editor will open up. Do a track of your commits from github UI and opened editor and change the messages.

    0 讨论(0)
  • 2020-12-07 09:46

    GitHub's instructions for doing this:

    1. On the command line, navigate to the repository that contains the commit you want to amend.
    2. Type git commit --amend and press Enter.
    3. In your text editor, edit the commit message and save the commit.
    4. Use the git push --force example-branch command to force push over the old commit.

    Source: https://help.github.com/articles/changing-a-commit-message/

    0 讨论(0)
  • 2020-12-07 09:51

    No, this is not directly possible. The hash for every Git commit is also calculated based on the commit message. When you change the commit message, you change the commit hash. If you want to push that commit, you have to force that push (git push -f). But if already someone pulled your old commit and started a work based on that commit, he would have to rebase his work onto your new commit.

    0 讨论(0)
  • 2020-12-07 09:53

    For intellij users: If you want to make changes in interactive way for past commits, which are not pushed follow below steps in Intellij:

    • Select Version Control
    • Select Log
    • Right click the commit for which you want to amend comment
    • Click reword
    • Done

    Hope it helps

    0 讨论(0)
  • 2020-12-07 09:53

    For Android Studio / intellij users:

    • Select Version Control
    • Select Log
    • Right click the commit for which you want to rename
    • Click Edit Commit Message
    • Write your commit message
    • Done
    0 讨论(0)
提交回复
热议问题