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 trial

Development Tools Git Basics Getting Started With Git Committing Changes

Can't write a message to git commit

So I'm following along on my own computer's terminal (a 2009 macbook) and everything was working until I had to do a git commit for the README file. After I open git commit and write the message at the top, it won't let me exit using ^x (control-x). In fact, it just brings up a message at the bottom that says "-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)"

So, I looked online on how to exit git commit, and found some suggestions (press esc, then q) but that brings up an error, which says "E37: No write since last change (add ! to override)" so naturally, I added the ! and force quit the git commit, but that eliminates it from saving my changes! How the heck do I make this work??

3 Answers

Jane Eyer
Jane Eyer
2,586 Points

If ctrl + x does not work for you then your git is using vim. In that case, Press esc and type ":wq" (w- means for write, q - means for quit) and press enter.

In the future if you want to use nano as a default text editor. then go to the main screen on terminal. type: nano ~/.gitconfig

The above command line will open an empty file and in the empty file type: git config core.editor "nano"

then press ctrl + x and enter to save and get out.

Happy gitting :D

Thank you! This is exactly the answer I was looking for.

Benjamin, are you using nano to edit the commit message? That's what he's doing. Also, you use Crtl-O to write out your edits, then Ctrl-X to exit in nano.

hey git by default uses vim for commit messages to exit vim you press ESC then :q ENTER

or you can commit using 'git commit -m "Your message"

Yes but as I was saying I tried that and it gave me that E37 error message. Using 'git commit -m "Your Message"' worked but I was just wondering why I can't do it the same way he did it in the video.