I did a commit in SourceTree (Bitbucket git repository) and then realized I forgot to add something to the comment. Is there a way to update only the comment?
You have to use amend to change the commit message. Press the commit button and select "Amend latest commit" from the commit options on the right, above the commit message box.
If your commit was already pushed to the server, your push will be rejected afterwards. In this case you have to do a force push from the command line (git push --force) or another Git client that has this option. N.B. Your repository might be configured to reject force pushes. In this case, there is no way for you to change the commit on the server.
You really shouldn't use force push to do this on an already-pushed commit anyway, if there's any chance that other developers have pulled that commit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I tried to use ‘Amend latest commit’ and it asks whether I want to replace comment with message from previous commit which made no sense to me in a first moment. Now I see the ‘Amend latest commit’ option remains selected (marked) which I guess means it will take effect when pressing Commit button, correct? I’ll try that on commit messages not pushed to remote repository. I think I won’t try the force push option, I’m still kind of newbie on Git and don’t want to make a mess. Thanks for your replies.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That question is only about whether you want to load and edit the previous commit message or start with a blank text. Whichever you choose, it will overwrite the commit message of the last commit with whatever you have when you press the commit button.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.