Is there a way to edit a commit message on GitHub?












93















Is there a way to edit a commit message after committing and pushing to GitHub? I see that there is a 'add a note' as well as inline commenting, but no actual editing of a commit message. There is also 'amend commit' in git extensions but that doesn't edit the existing message.










share|improve this question

























  • You can try reverting the commit (see some options in this SO question: stackoverflow.com/questions/4114095/…) - only make sure you first back up any code changes so you won't lose those for the sake of a comment!

    – Traveling Tech Guy
    May 9 '14 at 17:25











  • See also How do I edit an incorrect commit message in Git? on Stack Overflow.

    – Arjan
    May 10 '14 at 10:38
















93















Is there a way to edit a commit message after committing and pushing to GitHub? I see that there is a 'add a note' as well as inline commenting, but no actual editing of a commit message. There is also 'amend commit' in git extensions but that doesn't edit the existing message.










share|improve this question

























  • You can try reverting the commit (see some options in this SO question: stackoverflow.com/questions/4114095/…) - only make sure you first back up any code changes so you won't lose those for the sake of a comment!

    – Traveling Tech Guy
    May 9 '14 at 17:25











  • See also How do I edit an incorrect commit message in Git? on Stack Overflow.

    – Arjan
    May 10 '14 at 10:38














93












93








93


32






Is there a way to edit a commit message after committing and pushing to GitHub? I see that there is a 'add a note' as well as inline commenting, but no actual editing of a commit message. There is also 'amend commit' in git extensions but that doesn't edit the existing message.










share|improve this question
















Is there a way to edit a commit message after committing and pushing to GitHub? I see that there is a 'add a note' as well as inline commenting, but no actual editing of a commit message. There is also 'amend commit' in git extensions but that doesn't edit the existing message.







git github






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 27 at 16:41









Community

1




1










asked May 9 '14 at 16:48









Matthew PetersMatthew Peters

8131814




8131814













  • You can try reverting the commit (see some options in this SO question: stackoverflow.com/questions/4114095/…) - only make sure you first back up any code changes so you won't lose those for the sake of a comment!

    – Traveling Tech Guy
    May 9 '14 at 17:25











  • See also How do I edit an incorrect commit message in Git? on Stack Overflow.

    – Arjan
    May 10 '14 at 10:38



















  • You can try reverting the commit (see some options in this SO question: stackoverflow.com/questions/4114095/…) - only make sure you first back up any code changes so you won't lose those for the sake of a comment!

    – Traveling Tech Guy
    May 9 '14 at 17:25











  • See also How do I edit an incorrect commit message in Git? on Stack Overflow.

    – Arjan
    May 10 '14 at 10:38

















You can try reverting the commit (see some options in this SO question: stackoverflow.com/questions/4114095/…) - only make sure you first back up any code changes so you won't lose those for the sake of a comment!

– Traveling Tech Guy
May 9 '14 at 17:25





You can try reverting the commit (see some options in this SO question: stackoverflow.com/questions/4114095/…) - only make sure you first back up any code changes so you won't lose those for the sake of a comment!

– Traveling Tech Guy
May 9 '14 at 17:25













See also How do I edit an incorrect commit message in Git? on Stack Overflow.

– Arjan
May 10 '14 at 10:38





See also How do I edit an incorrect commit message in Git? on Stack Overflow.

– Arjan
May 10 '14 at 10:38










4 Answers
4






active

oldest

votes


















128
















  1. git rebase -i <commit hash you want to change>^



    This will open your default editor (usually vi) with a list of commits and actions for each one. By default, the action is pick.



  2. For any commit you wish to change the message, change pick to reword.


  3. Save and quit (in vi: :wq).



  4. For each such commit, you'll get an editor to edit the commit message. Change it as you see fit, save and quit.



    Once you're done editing all the commit messages, you'll return to the command prompt, and have a new tree with the updated messages.



  5. You can now upload them to github by using git push origin --force.



If you just need to fix your last commit, you can replace steps 1-4 with git commit --amend.






share|improve this answer





















  • 2





    @MatthewPeters I assume there should be a way, but I don't know - I use the commandline directly.

    – Mureinik
    May 15 '14 at 15:13






  • 2





    It does not seem that you can specify <commit hash you want to change>, rather you need to specify the hash of the commit preceding the one you want to change or use the HEAD~x where x is the number of commits from HEAD where the item you wish to change resides.

    – ssc327
    Dec 18 '18 at 21:32






  • 2





    @ssc327 Note that I a ^ there - I indeed suggested rebasing on the parent of the commit you want to change.

    – Mureinik
    Dec 19 '18 at 5:16






  • 2





    @Murenik you are correct, I somehow missed seeing the ^

    – ssc327
    Dec 19 '18 at 11:41






  • 1





    @deadfish Using the Windows command line, you must type ^^ to end the command with a literal ^ e.g.: git rebase -i 2c747b32^^

    – Wyck
    Feb 15 at 0:59



















25














In Intellij Idea you can do it so easy.




  1. Open Version Control (History)

  2. Select log tab

  3. Select commit to change comment

  4. press F2 (Mac fn + F2), and update your commit message






share|improve this answer





















  • 2





    What a good tool.

    – g10guang
    Nov 2 '18 at 3:21











  • Not working if you already pushed to remote.

    – paynd
    Nov 5 '18 at 10:45






  • 4





    You've got to execute git push origin --force afterwards as suggested in @Mureinik's answer.

    – Dan Macák
    Nov 15 '18 at 8:21











  • works perfect with android studio as well.

    – Rat-a-tat-a-tat Ratatouille
    Jan 9 at 16:57











  • The "reword" option is disabled if the commit has been pushed already.

    – huyz
    Jan 10 at 12:43



















2














Another option is to create an additional "errata commit" (and push) which references the commit object that contains the error -- the new errata commit also provides the correction. An errata commit is a commit with no substantive code changes but an important commit message -- for example, add one space character to your readme file and commit that change with the important commit message, or use the git option --allow-empty. It's certainly easier and safer than rebasing, it doesn't modify true history, and it keeps the branch tree clean (using amend is also a good choice if you are correcting the most recent commit, but an errata commit may be a good choice for older commits). This type of thing so rarely happens that simply documenting the mistake is good enough. In the future, if you need to search through a git log for a feature keyword, the original (erroneous) commit may not appear because the wrong keyword was used in that original commit (the original typo) -- however, the keyword will appear in the errata commit which will then point you to the original commit that had the typo. Here's an example:




$ git log
commit 0c28141c68adae276840f17ccd4766542c33cf1d
Author: First Last
Date: Wed Aug 8 15:55:52 2018 -0600

Errata commit:
This commit has no substantive code change.
THis commit is provided only to document a correction to a previous commit message.
This pertains to commit object e083a7abd8deb5776cb304fa13731a4182a24be1
Original incorrect commit message:
Changed background color to red
Correction (*change highlighted*):
Changed background color to *blue*

commit 032d0ff0601bff79bdef3c6f0a02ebfa061c4ad4
Author: First Last
Date: Wed Aug 8 15:43:16 2018 -0600

Some interim commit message

commit e083a7abd8deb5776cb304fa13731a4182a24be1
Author: First Last
Date: Wed Aug 8 13:31:32 2018 -0600

Changed background color to red





share|improve this answer

































    1














    if your git-graph looks like ...



    O   target-commit that you want to change its message [df9c192]
    |
    O parent-commit [b7ec061]
    |
    O


    (df9c192 and b7ec061 are the commit hashes of target-commit and parent-commit, separately)



    you can just type the following instructions...



    git reset --soft b7ec061
    git commit -m "your_new_description"
    git push -f


    Explanation:





    1. git reset --soft b7ec061 will keep your changes of files and reset to parent-commit (i.e. b7ec061)


    2. git commit -m "..." will locally create a new commit


    3. git push -f will push your new commit to the server and replace the old one (i.e. df9c192)






    share|improve this answer


























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f751699%2fis-there-a-way-to-edit-a-commit-message-on-github%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      128
















      1. git rebase -i <commit hash you want to change>^



        This will open your default editor (usually vi) with a list of commits and actions for each one. By default, the action is pick.



      2. For any commit you wish to change the message, change pick to reword.


      3. Save and quit (in vi: :wq).



      4. For each such commit, you'll get an editor to edit the commit message. Change it as you see fit, save and quit.



        Once you're done editing all the commit messages, you'll return to the command prompt, and have a new tree with the updated messages.



      5. You can now upload them to github by using git push origin --force.



      If you just need to fix your last commit, you can replace steps 1-4 with git commit --amend.






      share|improve this answer





















      • 2





        @MatthewPeters I assume there should be a way, but I don't know - I use the commandline directly.

        – Mureinik
        May 15 '14 at 15:13






      • 2





        It does not seem that you can specify <commit hash you want to change>, rather you need to specify the hash of the commit preceding the one you want to change or use the HEAD~x where x is the number of commits from HEAD where the item you wish to change resides.

        – ssc327
        Dec 18 '18 at 21:32






      • 2





        @ssc327 Note that I a ^ there - I indeed suggested rebasing on the parent of the commit you want to change.

        – Mureinik
        Dec 19 '18 at 5:16






      • 2





        @Murenik you are correct, I somehow missed seeing the ^

        – ssc327
        Dec 19 '18 at 11:41






      • 1





        @deadfish Using the Windows command line, you must type ^^ to end the command with a literal ^ e.g.: git rebase -i 2c747b32^^

        – Wyck
        Feb 15 at 0:59
















      128
















      1. git rebase -i <commit hash you want to change>^



        This will open your default editor (usually vi) with a list of commits and actions for each one. By default, the action is pick.



      2. For any commit you wish to change the message, change pick to reword.


      3. Save and quit (in vi: :wq).



      4. For each such commit, you'll get an editor to edit the commit message. Change it as you see fit, save and quit.



        Once you're done editing all the commit messages, you'll return to the command prompt, and have a new tree with the updated messages.



      5. You can now upload them to github by using git push origin --force.



      If you just need to fix your last commit, you can replace steps 1-4 with git commit --amend.






      share|improve this answer





















      • 2





        @MatthewPeters I assume there should be a way, but I don't know - I use the commandline directly.

        – Mureinik
        May 15 '14 at 15:13






      • 2





        It does not seem that you can specify <commit hash you want to change>, rather you need to specify the hash of the commit preceding the one you want to change or use the HEAD~x where x is the number of commits from HEAD where the item you wish to change resides.

        – ssc327
        Dec 18 '18 at 21:32






      • 2





        @ssc327 Note that I a ^ there - I indeed suggested rebasing on the parent of the commit you want to change.

        – Mureinik
        Dec 19 '18 at 5:16






      • 2





        @Murenik you are correct, I somehow missed seeing the ^

        – ssc327
        Dec 19 '18 at 11:41






      • 1





        @deadfish Using the Windows command line, you must type ^^ to end the command with a literal ^ e.g.: git rebase -i 2c747b32^^

        – Wyck
        Feb 15 at 0:59














      128












      128








      128









      1. git rebase -i <commit hash you want to change>^



        This will open your default editor (usually vi) with a list of commits and actions for each one. By default, the action is pick.



      2. For any commit you wish to change the message, change pick to reword.


      3. Save and quit (in vi: :wq).



      4. For each such commit, you'll get an editor to edit the commit message. Change it as you see fit, save and quit.



        Once you're done editing all the commit messages, you'll return to the command prompt, and have a new tree with the updated messages.



      5. You can now upload them to github by using git push origin --force.



      If you just need to fix your last commit, you can replace steps 1-4 with git commit --amend.






      share|improve this answer

















      1. git rebase -i <commit hash you want to change>^



        This will open your default editor (usually vi) with a list of commits and actions for each one. By default, the action is pick.



      2. For any commit you wish to change the message, change pick to reword.


      3. Save and quit (in vi: :wq).



      4. For each such commit, you'll get an editor to edit the commit message. Change it as you see fit, save and quit.



        Once you're done editing all the commit messages, you'll return to the command prompt, and have a new tree with the updated messages.



      5. You can now upload them to github by using git push origin --force.



      If you just need to fix your last commit, you can replace steps 1-4 with git commit --amend.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jan 25 '16 at 11:44

























      answered May 10 '14 at 10:27









      MureinikMureinik

      2,87671725




      2,87671725








      • 2





        @MatthewPeters I assume there should be a way, but I don't know - I use the commandline directly.

        – Mureinik
        May 15 '14 at 15:13






      • 2





        It does not seem that you can specify <commit hash you want to change>, rather you need to specify the hash of the commit preceding the one you want to change or use the HEAD~x where x is the number of commits from HEAD where the item you wish to change resides.

        – ssc327
        Dec 18 '18 at 21:32






      • 2





        @ssc327 Note that I a ^ there - I indeed suggested rebasing on the parent of the commit you want to change.

        – Mureinik
        Dec 19 '18 at 5:16






      • 2





        @Murenik you are correct, I somehow missed seeing the ^

        – ssc327
        Dec 19 '18 at 11:41






      • 1





        @deadfish Using the Windows command line, you must type ^^ to end the command with a literal ^ e.g.: git rebase -i 2c747b32^^

        – Wyck
        Feb 15 at 0:59














      • 2





        @MatthewPeters I assume there should be a way, but I don't know - I use the commandline directly.

        – Mureinik
        May 15 '14 at 15:13






      • 2





        It does not seem that you can specify <commit hash you want to change>, rather you need to specify the hash of the commit preceding the one you want to change or use the HEAD~x where x is the number of commits from HEAD where the item you wish to change resides.

        – ssc327
        Dec 18 '18 at 21:32






      • 2





        @ssc327 Note that I a ^ there - I indeed suggested rebasing on the parent of the commit you want to change.

        – Mureinik
        Dec 19 '18 at 5:16






      • 2





        @Murenik you are correct, I somehow missed seeing the ^

        – ssc327
        Dec 19 '18 at 11:41






      • 1





        @deadfish Using the Windows command line, you must type ^^ to end the command with a literal ^ e.g.: git rebase -i 2c747b32^^

        – Wyck
        Feb 15 at 0:59








      2




      2





      @MatthewPeters I assume there should be a way, but I don't know - I use the commandline directly.

      – Mureinik
      May 15 '14 at 15:13





      @MatthewPeters I assume there should be a way, but I don't know - I use the commandline directly.

      – Mureinik
      May 15 '14 at 15:13




      2




      2





      It does not seem that you can specify <commit hash you want to change>, rather you need to specify the hash of the commit preceding the one you want to change or use the HEAD~x where x is the number of commits from HEAD where the item you wish to change resides.

      – ssc327
      Dec 18 '18 at 21:32





      It does not seem that you can specify <commit hash you want to change>, rather you need to specify the hash of the commit preceding the one you want to change or use the HEAD~x where x is the number of commits from HEAD where the item you wish to change resides.

      – ssc327
      Dec 18 '18 at 21:32




      2




      2





      @ssc327 Note that I a ^ there - I indeed suggested rebasing on the parent of the commit you want to change.

      – Mureinik
      Dec 19 '18 at 5:16





      @ssc327 Note that I a ^ there - I indeed suggested rebasing on the parent of the commit you want to change.

      – Mureinik
      Dec 19 '18 at 5:16




      2




      2





      @Murenik you are correct, I somehow missed seeing the ^

      – ssc327
      Dec 19 '18 at 11:41





      @Murenik you are correct, I somehow missed seeing the ^

      – ssc327
      Dec 19 '18 at 11:41




      1




      1





      @deadfish Using the Windows command line, you must type ^^ to end the command with a literal ^ e.g.: git rebase -i 2c747b32^^

      – Wyck
      Feb 15 at 0:59





      @deadfish Using the Windows command line, you must type ^^ to end the command with a literal ^ e.g.: git rebase -i 2c747b32^^

      – Wyck
      Feb 15 at 0:59













      25














      In Intellij Idea you can do it so easy.




      1. Open Version Control (History)

      2. Select log tab

      3. Select commit to change comment

      4. press F2 (Mac fn + F2), and update your commit message






      share|improve this answer





















      • 2





        What a good tool.

        – g10guang
        Nov 2 '18 at 3:21











      • Not working if you already pushed to remote.

        – paynd
        Nov 5 '18 at 10:45






      • 4





        You've got to execute git push origin --force afterwards as suggested in @Mureinik's answer.

        – Dan Macák
        Nov 15 '18 at 8:21











      • works perfect with android studio as well.

        – Rat-a-tat-a-tat Ratatouille
        Jan 9 at 16:57











      • The "reword" option is disabled if the commit has been pushed already.

        – huyz
        Jan 10 at 12:43
















      25














      In Intellij Idea you can do it so easy.




      1. Open Version Control (History)

      2. Select log tab

      3. Select commit to change comment

      4. press F2 (Mac fn + F2), and update your commit message






      share|improve this answer





















      • 2





        What a good tool.

        – g10guang
        Nov 2 '18 at 3:21











      • Not working if you already pushed to remote.

        – paynd
        Nov 5 '18 at 10:45






      • 4





        You've got to execute git push origin --force afterwards as suggested in @Mureinik's answer.

        – Dan Macák
        Nov 15 '18 at 8:21











      • works perfect with android studio as well.

        – Rat-a-tat-a-tat Ratatouille
        Jan 9 at 16:57











      • The "reword" option is disabled if the commit has been pushed already.

        – huyz
        Jan 10 at 12:43














      25












      25








      25







      In Intellij Idea you can do it so easy.




      1. Open Version Control (History)

      2. Select log tab

      3. Select commit to change comment

      4. press F2 (Mac fn + F2), and update your commit message






      share|improve this answer















      In Intellij Idea you can do it so easy.




      1. Open Version Control (History)

      2. Select log tab

      3. Select commit to change comment

      4. press F2 (Mac fn + F2), and update your commit message







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jul 13 '18 at 14:28









      Nathan.Eilisha Shiraini

      2,4431923




      2,4431923










      answered Jun 18 '18 at 9:49









      fedrbodrfedrbodr

      35922




      35922








      • 2





        What a good tool.

        – g10guang
        Nov 2 '18 at 3:21











      • Not working if you already pushed to remote.

        – paynd
        Nov 5 '18 at 10:45






      • 4





        You've got to execute git push origin --force afterwards as suggested in @Mureinik's answer.

        – Dan Macák
        Nov 15 '18 at 8:21











      • works perfect with android studio as well.

        – Rat-a-tat-a-tat Ratatouille
        Jan 9 at 16:57











      • The "reword" option is disabled if the commit has been pushed already.

        – huyz
        Jan 10 at 12:43














      • 2





        What a good tool.

        – g10guang
        Nov 2 '18 at 3:21











      • Not working if you already pushed to remote.

        – paynd
        Nov 5 '18 at 10:45






      • 4





        You've got to execute git push origin --force afterwards as suggested in @Mureinik's answer.

        – Dan Macák
        Nov 15 '18 at 8:21











      • works perfect with android studio as well.

        – Rat-a-tat-a-tat Ratatouille
        Jan 9 at 16:57











      • The "reword" option is disabled if the commit has been pushed already.

        – huyz
        Jan 10 at 12:43








      2




      2





      What a good tool.

      – g10guang
      Nov 2 '18 at 3:21





      What a good tool.

      – g10guang
      Nov 2 '18 at 3:21













      Not working if you already pushed to remote.

      – paynd
      Nov 5 '18 at 10:45





      Not working if you already pushed to remote.

      – paynd
      Nov 5 '18 at 10:45




      4




      4





      You've got to execute git push origin --force afterwards as suggested in @Mureinik's answer.

      – Dan Macák
      Nov 15 '18 at 8:21





      You've got to execute git push origin --force afterwards as suggested in @Mureinik's answer.

      – Dan Macák
      Nov 15 '18 at 8:21













      works perfect with android studio as well.

      – Rat-a-tat-a-tat Ratatouille
      Jan 9 at 16:57





      works perfect with android studio as well.

      – Rat-a-tat-a-tat Ratatouille
      Jan 9 at 16:57













      The "reword" option is disabled if the commit has been pushed already.

      – huyz
      Jan 10 at 12:43





      The "reword" option is disabled if the commit has been pushed already.

      – huyz
      Jan 10 at 12:43











      2














      Another option is to create an additional "errata commit" (and push) which references the commit object that contains the error -- the new errata commit also provides the correction. An errata commit is a commit with no substantive code changes but an important commit message -- for example, add one space character to your readme file and commit that change with the important commit message, or use the git option --allow-empty. It's certainly easier and safer than rebasing, it doesn't modify true history, and it keeps the branch tree clean (using amend is also a good choice if you are correcting the most recent commit, but an errata commit may be a good choice for older commits). This type of thing so rarely happens that simply documenting the mistake is good enough. In the future, if you need to search through a git log for a feature keyword, the original (erroneous) commit may not appear because the wrong keyword was used in that original commit (the original typo) -- however, the keyword will appear in the errata commit which will then point you to the original commit that had the typo. Here's an example:




      $ git log
      commit 0c28141c68adae276840f17ccd4766542c33cf1d
      Author: First Last
      Date: Wed Aug 8 15:55:52 2018 -0600

      Errata commit:
      This commit has no substantive code change.
      THis commit is provided only to document a correction to a previous commit message.
      This pertains to commit object e083a7abd8deb5776cb304fa13731a4182a24be1
      Original incorrect commit message:
      Changed background color to red
      Correction (*change highlighted*):
      Changed background color to *blue*

      commit 032d0ff0601bff79bdef3c6f0a02ebfa061c4ad4
      Author: First Last
      Date: Wed Aug 8 15:43:16 2018 -0600

      Some interim commit message

      commit e083a7abd8deb5776cb304fa13731a4182a24be1
      Author: First Last
      Date: Wed Aug 8 13:31:32 2018 -0600

      Changed background color to red





      share|improve this answer






























        2














        Another option is to create an additional "errata commit" (and push) which references the commit object that contains the error -- the new errata commit also provides the correction. An errata commit is a commit with no substantive code changes but an important commit message -- for example, add one space character to your readme file and commit that change with the important commit message, or use the git option --allow-empty. It's certainly easier and safer than rebasing, it doesn't modify true history, and it keeps the branch tree clean (using amend is also a good choice if you are correcting the most recent commit, but an errata commit may be a good choice for older commits). This type of thing so rarely happens that simply documenting the mistake is good enough. In the future, if you need to search through a git log for a feature keyword, the original (erroneous) commit may not appear because the wrong keyword was used in that original commit (the original typo) -- however, the keyword will appear in the errata commit which will then point you to the original commit that had the typo. Here's an example:




        $ git log
        commit 0c28141c68adae276840f17ccd4766542c33cf1d
        Author: First Last
        Date: Wed Aug 8 15:55:52 2018 -0600

        Errata commit:
        This commit has no substantive code change.
        THis commit is provided only to document a correction to a previous commit message.
        This pertains to commit object e083a7abd8deb5776cb304fa13731a4182a24be1
        Original incorrect commit message:
        Changed background color to red
        Correction (*change highlighted*):
        Changed background color to *blue*

        commit 032d0ff0601bff79bdef3c6f0a02ebfa061c4ad4
        Author: First Last
        Date: Wed Aug 8 15:43:16 2018 -0600

        Some interim commit message

        commit e083a7abd8deb5776cb304fa13731a4182a24be1
        Author: First Last
        Date: Wed Aug 8 13:31:32 2018 -0600

        Changed background color to red





        share|improve this answer




























          2












          2








          2







          Another option is to create an additional "errata commit" (and push) which references the commit object that contains the error -- the new errata commit also provides the correction. An errata commit is a commit with no substantive code changes but an important commit message -- for example, add one space character to your readme file and commit that change with the important commit message, or use the git option --allow-empty. It's certainly easier and safer than rebasing, it doesn't modify true history, and it keeps the branch tree clean (using amend is also a good choice if you are correcting the most recent commit, but an errata commit may be a good choice for older commits). This type of thing so rarely happens that simply documenting the mistake is good enough. In the future, if you need to search through a git log for a feature keyword, the original (erroneous) commit may not appear because the wrong keyword was used in that original commit (the original typo) -- however, the keyword will appear in the errata commit which will then point you to the original commit that had the typo. Here's an example:




          $ git log
          commit 0c28141c68adae276840f17ccd4766542c33cf1d
          Author: First Last
          Date: Wed Aug 8 15:55:52 2018 -0600

          Errata commit:
          This commit has no substantive code change.
          THis commit is provided only to document a correction to a previous commit message.
          This pertains to commit object e083a7abd8deb5776cb304fa13731a4182a24be1
          Original incorrect commit message:
          Changed background color to red
          Correction (*change highlighted*):
          Changed background color to *blue*

          commit 032d0ff0601bff79bdef3c6f0a02ebfa061c4ad4
          Author: First Last
          Date: Wed Aug 8 15:43:16 2018 -0600

          Some interim commit message

          commit e083a7abd8deb5776cb304fa13731a4182a24be1
          Author: First Last
          Date: Wed Aug 8 13:31:32 2018 -0600

          Changed background color to red





          share|improve this answer















          Another option is to create an additional "errata commit" (and push) which references the commit object that contains the error -- the new errata commit also provides the correction. An errata commit is a commit with no substantive code changes but an important commit message -- for example, add one space character to your readme file and commit that change with the important commit message, or use the git option --allow-empty. It's certainly easier and safer than rebasing, it doesn't modify true history, and it keeps the branch tree clean (using amend is also a good choice if you are correcting the most recent commit, but an errata commit may be a good choice for older commits). This type of thing so rarely happens that simply documenting the mistake is good enough. In the future, if you need to search through a git log for a feature keyword, the original (erroneous) commit may not appear because the wrong keyword was used in that original commit (the original typo) -- however, the keyword will appear in the errata commit which will then point you to the original commit that had the typo. Here's an example:




          $ git log
          commit 0c28141c68adae276840f17ccd4766542c33cf1d
          Author: First Last
          Date: Wed Aug 8 15:55:52 2018 -0600

          Errata commit:
          This commit has no substantive code change.
          THis commit is provided only to document a correction to a previous commit message.
          This pertains to commit object e083a7abd8deb5776cb304fa13731a4182a24be1
          Original incorrect commit message:
          Changed background color to red
          Correction (*change highlighted*):
          Changed background color to *blue*

          commit 032d0ff0601bff79bdef3c6f0a02ebfa061c4ad4
          Author: First Last
          Date: Wed Aug 8 15:43:16 2018 -0600

          Some interim commit message

          commit e083a7abd8deb5776cb304fa13731a4182a24be1
          Author: First Last
          Date: Wed Aug 8 13:31:32 2018 -0600

          Changed background color to red






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 9 '18 at 15:14

























          answered Aug 8 '18 at 22:27









          rob_7ccrob_7cc

          212




          212























              1














              if your git-graph looks like ...



              O   target-commit that you want to change its message [df9c192]
              |
              O parent-commit [b7ec061]
              |
              O


              (df9c192 and b7ec061 are the commit hashes of target-commit and parent-commit, separately)



              you can just type the following instructions...



              git reset --soft b7ec061
              git commit -m "your_new_description"
              git push -f


              Explanation:





              1. git reset --soft b7ec061 will keep your changes of files and reset to parent-commit (i.e. b7ec061)


              2. git commit -m "..." will locally create a new commit


              3. git push -f will push your new commit to the server and replace the old one (i.e. df9c192)






              share|improve this answer






























                1














                if your git-graph looks like ...



                O   target-commit that you want to change its message [df9c192]
                |
                O parent-commit [b7ec061]
                |
                O


                (df9c192 and b7ec061 are the commit hashes of target-commit and parent-commit, separately)



                you can just type the following instructions...



                git reset --soft b7ec061
                git commit -m "your_new_description"
                git push -f


                Explanation:





                1. git reset --soft b7ec061 will keep your changes of files and reset to parent-commit (i.e. b7ec061)


                2. git commit -m "..." will locally create a new commit


                3. git push -f will push your new commit to the server and replace the old one (i.e. df9c192)






                share|improve this answer




























                  1












                  1








                  1







                  if your git-graph looks like ...



                  O   target-commit that you want to change its message [df9c192]
                  |
                  O parent-commit [b7ec061]
                  |
                  O


                  (df9c192 and b7ec061 are the commit hashes of target-commit and parent-commit, separately)



                  you can just type the following instructions...



                  git reset --soft b7ec061
                  git commit -m "your_new_description"
                  git push -f


                  Explanation:





                  1. git reset --soft b7ec061 will keep your changes of files and reset to parent-commit (i.e. b7ec061)


                  2. git commit -m "..." will locally create a new commit


                  3. git push -f will push your new commit to the server and replace the old one (i.e. df9c192)






                  share|improve this answer















                  if your git-graph looks like ...



                  O   target-commit that you want to change its message [df9c192]
                  |
                  O parent-commit [b7ec061]
                  |
                  O


                  (df9c192 and b7ec061 are the commit hashes of target-commit and parent-commit, separately)



                  you can just type the following instructions...



                  git reset --soft b7ec061
                  git commit -m "your_new_description"
                  git push -f


                  Explanation:





                  1. git reset --soft b7ec061 will keep your changes of files and reset to parent-commit (i.e. b7ec061)


                  2. git commit -m "..." will locally create a new commit


                  3. git push -f will push your new commit to the server and replace the old one (i.e. df9c192)







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 14 at 10:19

























                  answered Mar 14 at 7:29









                  Alumi LuAlumi Lu

                  112




                  112






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f751699%2fis-there-a-way-to-edit-a-commit-message-on-github%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Probability when a professor distributes a quiz and homework assignment to a class of n students.

                      Aardman Animations

                      Are they similar matrix