How to commit a change in git when git commit opens Nano?

Guy picture Guy · Jun 19, 2018 · Viewed 20.6k times · Source

I'm new to git and I'm trying to commit my first changes on a Windows machine. However, when I type in $git commit it takes me to a different screen than any online tutorials show or than what is mentioned in Pro Git. No online searching yields an explanation of how to use this screen, either.

The screen looks like this: The git commit screen I'm having trouble with

I have tried every key on the keyboard, but nothing seems to actually do the commit. Also there are all these little help options in green at the bottom of the screen that seem to be giving commands, but when I press the buttons they show it just types them into the commit message. What are those help options and how do I use them?

Everyone else seems to be using something called "vim" which I believe I chose not to install when installing Git because I thought the Windows console was fine.

So how do I actually commit and what are those green commands at the bottom of the screen? Thanks!

Answer

piedra picture piedra · Jun 19, 2018

That screen is just a text editor and those options at the bottom, represent commands, tipically its the ctrl key + the letter for the command.

To make the commit you should write your commit message, then press ctrl+o to write your message, and then ctrl+x to exit that screen.

To avoid that screen you could do something like git commit -m 'your commit message', the -m indicates that your commit message goes in the command.