0

I wanted to change a commit in Git for which I googled and found this command:

git commit --amend

When I pass this command, I get a screen which look something like this:

enter image description here

When I start typing commit here, it just plays sound similar to one that sort of means that I am typing in a wrong place (invalid command).

Can someone please help me in figuring out how we can edit a commit message in Git?

5
  • 7
    Your problem isn't with git, it's with vi. Either you learn vi or you configure git to use another editor. Commented Oct 20, 2018 at 5:32
  • 4
    I'm voting to close this question as off-topic because it isn't about programming but about how to type text in the vi editor Commented Oct 20, 2018 at 5:32
  • fast cheat sheet: Type i to enter some text, then esc, then :x and enter. Commented Oct 20, 2018 at 5:33
  • I like to use the ZZ shortcut to save and exit. Commented Oct 20, 2018 at 12:15
  • I think a simple answer should have been "what you are seeing is a vim terminal interface, as it shows on the bottom of your pasted screenshot" and then you can point him to vim documentation. Commented Sep 2, 2022 at 10:04

2 Answers 2

9

To edit a commit message in Git:

First as you have mentioned give the command:

git commit --amend

Then it will popup the screen you have given in your question.

Then press i which will make it possible to edit the commit message. Then move your cursor to the your previous commit message using arrow keys

Created Intial Schema

And edit it.

Next press Esc key on your keyboard.

Next type the command press Shift+; key on your keyboard

:

Then type wq after the colon. And press Enter save and exit.

:wq

Sign up to request clarification or add additional context in comments.

Comments

2

The shortest way to change the last commit do this is:

git commit -m "<new_message>" --amend

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.