Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Development Tools

Using Git Commit

Hello,

I am trying to follow the tutorial to use Git from treehouse. I already added git add readme.txt and would like to do git commit

After that, the terminal looks like this

Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Committer: Christian <Christian@Christians-MacBook-Pro.local>
#
# On branch master
#
# Initial commit
#
# Changes to be committed:
#       new file:   readme.txt
#
~
~
~
~
~
~
~
~
~
~

However, after I add the message above, I can't do anything to save, or exit, there is no help about command whatsoever at the bottom of the terminal. I tried ctrl x, cmd x, and some possible combinations just like what nano has. It didn't help.

Anyone knows whats wrong with my git? I am using git version 1.8.5.2(Apple Git-48)

4 Answers

Pedro GCA
Pedro GCA
20,683 Points

Hey Christian, It seems you are using vim as text editor and not nano. If Im right, the commands for vim are completely different of nano's. In this case there is nothing wrong with git, you are just doing some command mistakes.

Instructions: After type your message --> type "esc" to exit the insert mode (vim text editor mode) --> then type :w which means save the file --> then type :q which means quit vim. Then your commit will be ok. Test it and let me know. ;)

For more information about vim commands click here.

Hi Pedro,

It worked! Thank you so much. Just two more questions:

  1. How do I get the list of all commands in vim, if I want to get the list directly from vim. Because in nano, it shows all the commands at the bottom of the terminal, but not in vim.
  2. If I want to change it to nano as my text editor, how do I do that?
Stone Preston
Stone Preston
42,016 Points

type your commit message, then press the esc key, then type :wq.

For future reference, you can use the -m flag on your commit command to specify a message without using the default editor:

git commit -m "this is the commit message"

Thanks Stone, good idea, never thought about it!

Pedro GCA
Pedro GCA
20,683 Points

No worries Christian,

1st: I don't know exactly how to show up vim commands in the terminal like nano, I guess the software does not give us this option, just because is a different software.

2nd: to change your default text editor for git:

git config --global core.editor nano

For more information check git website.

I hope I helped.

Thank you, you helped me a lot!

If you just made some changes and want to add everything and commit everything, the following two commands make it pretty easy. I find myself using this combination all the time:

  • git add -A
  • git commit -a -m "Comment on changes made goes here"