Wednesday, December 16, 2015

Edit an incorrect commit message in Git

Edit an incorrect commit message in Git

Amending the commit message

git commit --amend
 
Will open your editor, allowing you to change the commit message of the most recent commit. Additionally, you can set the commit message directly in the command line with:

git commit --amend -m "New commit message"

 

Make sure you don't have any working copy changes staged before doing this or they will get committed too. (Unstaged changes will not get committed.)

Changing the message of a commit that you've already pushed to your remote branch

If you've already pushed your commit up to your remote branch, then you'll need to force push the commit with

git push <remote> <branch> --force
# Or
git push <remote> <branch> -f
 
Warning: force-pushing will overwrite the remote branch with the state of your local one. If there are commits on the remote branch that you don't have in your local branch, you will lose those commits.
Warning: be cautious about amending commits that you have already shared with other people. Amending commits essentially rewrites them to have different SHA IDs, which poses a problem if other people have copies of the old commit that you've rewritten. Anyone who has a copy of the old commit will need to re-synchronize their work with your newly re-written commit, which can sometimes be difficult, so make sure you coordinate with others when attempting to rewrite shared commit history, or just avoid rewriting shared commits altogether.

Documentation

19 comments:

  1. There are numerous new tools and applications used in order to make way for faster and better programming.
    php development company sydney

    ReplyDelete
  2. Custom web development is the most effective way to build a creative website with stunning design. would like to appreciate your work. Thank you so much for sharing.

    ReplyDelete
  3. PHP Training in chennai
    Creating Experts provide Real Time scenarios PHP training in Chennai.At creating experts the trainers have around 8+ years of experience.They teach the advance level topics by giving real time examples.
    Contact us: 8122241286, 9003085882 – Karthick
    Here everything is practical basis not any classroom training.The trainers are working in mnc's and they will take classes only on Saturday and Sunday.
    Ref link : http://thecreatingexperts.com/php-training-in-chennai/

    ReplyDelete
  4. Thanks for sharing this Information, Got to learn new things from your Blog on PHP.
    Ref link : http://thecreatingexperts.com/php-training-in-chennai/

    ReplyDelete

  5. Thanks for the great information in your blog PHP

    ReplyDelete
  6. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about PHP.
    http://thecreatingexperts.com/php-training-in-chennai/

    ReplyDelete
  7. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about php

    ReplyDelete

  8. ever best friendly advertising networks find having over 10000 worldwide ad networks find Ad network cpm cpc cpi cpa

    ReplyDelete
  9. Blogs are so informative where we get lots of information on any topic. Nice job keep it up!! asp.net training in jalandhar

    ReplyDelete
  10. Thanks a lot for your valuable article. I will keep following your blog for more information.

    ReplyDelete
  11. My friend Suggest me this blog and I can say this is the best blog to get the basic knowledge.Thank you so much for this Selenium Training in Chennai

    ReplyDelete
  12. Thanks for sharing this Information, Got to learn new things from your Blog on Appium.
    Appium training in chennai

    ReplyDelete
  13. Nice idea. Brief and well written; keep it up

    ReplyDelete
  14. It was very nice blog to learn about Selenium.Thanks for sharing new things.selenium training in chennai

    ReplyDelete
  15. Nice info about Php it’s reallyhelpful…. If it possible share some more tutorials……….

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...