Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialFNU Christian
5,549 PointsUsing 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
20,683 PointsHey 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.
Stone Preston
42,016 Pointstype 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"
FNU Christian
5,549 PointsThanks Stone, good idea, never thought about it!
Pedro GCA
20,683 PointsNo 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.
FNU Christian
5,549 PointsThank you, you helped me a lot!
Mitch Maynard
12,953 PointsIf 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"
FNU Christian
5,549 PointsFNU Christian
5,549 PointsHi Pedro,
It worked! Thank you so much. Just two more questions: