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

Ruby

Ossian MacDonald
Ossian MacDonald
2,175 Points

Put git commit instead of git commit -m

Hi All,

I am working on the adding interactivity section of the treebook project, and I made a mistake in the counsel in the process of adding to github. I put git commit instead of git commit -m, and it opened vim. Not I can't get out to continue the process! Rudimentary I'm sure, but I've looked at a few websites to no avail. The message I get from the counsel is: "Please enter the commit message for your changes. Lines starting

with '#' will be ignored, and an empty message aborts the commit.

On branch master"

How do I get out of vim so I can use the git commit -m command? Cheers!

2 Answers

When you write just git commit, your command line opens up your default editor, which like you said was vim.

Without the "m", you're telling git you want to write more than what you can write in the command line, so git opens up the text editor.

You can write your commit right into the editor (Vim) just by switching to insert mode (type "i"), writing your commit, exiting out of insert mode (usually this is escape or double escape), saving (type ":w", this should show up at the bottom of your command line) and quitting (type ":q"). This will commit your changes.

If you really don't want to use Vim, then you can just exit (":q"), but it won't commit your changes.

Cheers!

EDIT: I would like to say that making "git commit -m" a habit may or may not be a good thing depending on your commits. I like explaining what each commit does in length so that the next developer knows exactly why I did the way I did things.

Ossian MacDonald
Ossian MacDonald
2,175 Points

Success! Thanks for taking the time to explain this in detail. I really appreciate the time!