We make mistakes. One such mistake we usually do are git messages. There could be a number of things we did wrong.
- We need it be in a certain format to talk to some API i.e. Pivotaltracker
- You have a format that you use in your workplace
- You simply wrote the wrong commit message for some reason
It is so much easier if your commit is still on your local machine
You should of course go to the folder root of your git repository
This is where I mistakenly added the commit message,
$ git commit -m "nothing important" [staging 1e65441] nothing important 1 file changed, 1 deletion(-)
Type git commit —amend and press Enter.
This will open up vim or your preferred editor
# Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Fri Jul 1 17:55:42 2016 +0800 # # On branch staging # Your branch and 'origin/staging' have diverged, # and have 2 and 15 different commits each, respectively. # (use "git pull" to merge the remote branch into yours)
Type in your preferred commit message, there is really nothing important and then save
[staging 41de22f] there is really nothing important Date: Fri Jul 1 17:55:42 2016 +0800 1 file changed, 1 insertion(+), 1 deletion(-)
Your commit message has now been changed.
git log commit 41de22f1af956be5e38c2ed377d26672ae0c7bb1 Author: meme <firstname.lastname@example.org> Date: Fri Jul 1 17:55:42 2016 +0800
there is really nothing important