<p>In all the Git tutorials I've read they say that you can do:</p>

<pre><code>git init
git add .
git commit
</code></pre>

<p>When I do that I get a big text file opened up. None of the tutorials seem to address this, so I don't know what to do with the file or what to put in it if anything.</p>

[{'answer_id': 60283, 'author': 'Ben Collins', 'author_id': 3279, 'author_profile': 'https://Stackoverflow.com/users/3279', 'pm_score': 3, 'selected': False, 'text': '<p>The <code>git commit</code> command will open up the editor specified in the <code>EDITOR</code> environment variable so you can enter a commit comment.  On a Linux or BSD system, this should be vi by default, although any editor should work.</p>\n\n<p>Just enter your comments and save the file.</p>\n'}, {'answer_id': 60284, 'author': 'Greg Hewgill', 'author_id': 893, 'author_profile': 'https://Stackoverflow.com/users/893', 'pm_score': 4, 'selected': False, 'text': '<p>The <code>-m</code> option to commit lets you enter a commit message on the command line:</p>\n\n<pre><code>git commit -m "my first commit"\n</code></pre>\n'}, {'answer_id': 60286, 'author': 'Lou', 'author_id': 4341, 'author_profile': 'https://Stackoverflow.com/users/4341', 'pm_score': 5, 'selected': False, 'text': '<p>The text file that is being opened is a summary of the current commit operation. The git commit drops you into this file so the you can add a commit message at the top of the file. Once you\'ve added your message just save and exit from this file.</p>\n\n<p>There is also a "-m msg" switch on this command that allows you to add the commit message on the command line.</p>\n'}, {'answer_id': 60292, 'author': 'Flame', 'author_id': 5387, 'author_profile': 'https://Stackoverflow.com/users/5387', 'pm_score': 1, 'selected': False, 'text': '<p>When doing revision control, you should always explain what the changed you made are. Usually the first time you\'re have a comment such as "Initial Commit."</p>\n\n<p>However in the long run you want to make a good comment for each commit. You will want something of the form:</p>\n\n<blockquote>\n  <p>Added experimental feature x.</p>\n  \n  <p>X will increase the performance of\n  feature Y in condition Z. Should you\n  need X activate it with the -x or\n  --feature-eks switches. This addresses feature request #1138.</p>\n</blockquote>\n'}, {'answer_id': 60311, 'author': 'Will Robertson', 'author_id': 4161, 'author_profile': 'https://Stackoverflow.com/users/4161', 'pm_score': 6, 'selected': False, 'text': '<p>As mentioned by <a href="https://stackoverflow.com/questions/60278/git-commit-text-file#60283">Ben Collins</a>, without the <code>-m "..."</code> argument to type the commit inline (which is generally a bad idea as it encourages you to be brief), this "big text file" that is opened up is a window in which to type the commit message.</p>\n\n<p>Usually it\'s recommended to write a summary in the first line, skip a line, and then write more detailed notes beneath; this helps programs that do things like email the commit messages with an appropriate subject line and the full list of changes made in the body.</p>\n\n<p>Instead of changing the <code>EDITOR</code> shell variable, you can also change the editor used by adding the additional lines in your <code>~/.gitconfig</code> file:</p>\n\n<pre><code>[core]\n    editor = emacs\n    excludesfile = /Users/will/.gitignore\n</code></pre>\n\n<p>That second line actually has nothing to do with your problem, but I find it really useful so I can populate my <code>~/.gitignore</code> file with all those filetypes I <em>know</em> I\'ll never, ever, want to commit to a repository.</p>\n'}, {'answer_id': 60320, 'author': 'Tom Martin', 'author_id': 5303, 'author_profile': 'https://Stackoverflow.com/users/5303', 'pm_score': 1, 'selected': False, 'text': '<p>Yeah, make sure you have a sensible editor set.  Not sure what your default editor will be but if, like me, it is <code>nano</code> (it will say so somewhere near the top after you type commit) you just need to type in a comment and then hit <kbd>Ctrl</kbd>-<kbd>X</kbd> to finish.  Then hit <kbd>y</kbd>, followed by <kbd>enter</kbd> to affirm the commit.</p>\n<p>Also, if you want to see a simple list of the files you\'ll be committing rather than a huge diff listing beforehand try</p>\n<pre class="lang-sh prettyprint-override"><code>git diff --name-only\n</code></pre>\n'}, {'answer_id': 466803, 'author': 'Stephen Bailey', 'author_id': 15385, 'author_profile': 'https://Stackoverflow.com/users/15385', 'pm_score': 4, 'selected': False, 'text': '<p>As all have said this is just where you add your commit comment - but for some it may still be confusing esp if you have not configured your editor settings, and you are not aware of what <a href="http://en.wikipedia.org/wiki/Vi" rel="noreferrer">VI</a> is : then you could be in for a shock, because you will think you are still in the GIT-Bash</p>\n\n<p>In that case you are in fact in a text editor with some interesting ways of dealing with things and <a href="http://www.tuxfiles.org/linuxhelp/vimcheat.html" rel="noreferrer">this set of commands</a> may help you out so that you can get past your first commit and then configure an editor you are familiar with or use it as an opportunity to  learn how to use it.</p>\n'}, {'answer_id': 532094, 'author': 'vikhyat', 'author_id': 257349, 'author_profile': 'https://Stackoverflow.com/users/257349', 'pm_score': 7, 'selected': False, 'text': '<p>You\'re meant to put the commit message in this text file, then save and quit.</p>\n\n<p>You can change the default text editor that git uses with this command:</p>\n\n<pre><code>git config --global core.editor "nano"\n</code></pre>\n\n<p>You have to change nano to whatever command would normally open your text editor.</p>\n'}, {'answer_id': 1077672, 'author': 'PHLAK', 'author_id': 27025, 'author_profile': 'https://Stackoverflow.com/users/27025', 'pm_score': 0, 'selected': False, 'text': '<p>The following is probably the easiest way to commit all changes:</p>\n\n<pre><code>git commit -a -m "Type your commit message here..."\n</code></pre>\n\n<p>Of course there are much more detailed ways of committing, but that should get you started.</p>\n'}, {'answer_id': 1385246, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 4, 'selected': False, 'text': '<p>If you’re on Mac OS X and using BBEdit, you can set this up as the editor of choice for commit messages:</p>\n\n<pre><code>git config --global core.editor "bbedit -w"\n</code></pre>\n\n<p>Once finished edit, save and close the file and git will use it for the comments.</p>\n'}, {'answer_id': 1464333, 'author': 'TheGeoff', 'author_id': 18095, 'author_profile': 'https://Stackoverflow.com/users/18095', 'pm_score': 3, 'selected': False, 'text': '<p>Try Escape then ZZ, after you\'re done typing your message.\nAs others have said when you run that commit command it actually runs a text editor to enter the message into.\nIn my case (OS X) it was VI, which I figured out after some digging around.\nIn that case, hit Escape to go into "command" mode (as opposed to INSERT mode) the enter ZZ. I\'m sure there are other ways of accomplishing the task but that did it for me.\nHaving never used VI or emacs it wasn\'t readily apparent to me and wasn\'t mentioned in any of the beginner guides I was using.\nHopefully this helps.</p>\n'}, {'answer_id': 2988154, 'author': 'user360221', 'author_id': 360221, 'author_profile': 'https://Stackoverflow.com/users/360221', 'pm_score': 2, 'selected': False, 'text': '<p>I was confused because I kept trying to enter a filename after the :w in VIM.  That doesn\'t trigger the commit.  Instead I kept getting a message "Aborting commit due to empty commit message." Don\'t put a filename after the :w. :w saves the file to .git/COMMIT_EDITMSG by default.  Then :q to exit to complete the commit. You can see the results with git log.</p>\n'}, {'answer_id': 3983599, 'author': 'Yarito', 'author_id': 482433, 'author_profile': 'https://Stackoverflow.com/users/482433', 'pm_score': 1, 'selected': False, 'text': '<p>Being new to Terminal as well, "Escape and then ZZ" worked for me, I\'ve been having this issue for months and also couldn\'t find a way around it. </p>\n\n<p>Thanks TheGeoff for your simple advice!</p>\n'}, {'answer_id': 4658092, 'author': 'Peter', 'author_id': 571309, 'author_profile': 'https://Stackoverflow.com/users/571309', 'pm_score': 2, 'selected': False, 'text': '<p>Now that I\'ve changed my editor to emacs, everything work fine.</p>\n\n<p>But before I set this, "git commit -a" did open gedit, but also immediately ended with a "Aborting commit due to empty commit message.".  Saving the file from gedit had no effect.  Explicitly setting the editor with "git config --global core.editor "gedit"" had the same result.</p>\n\n<p>There\'s nothing wrong with emacs, but out of curiosity why doesn\'t this work with gedit, and is there any way to get it to work?</p>\n\n<p>Thanks.</p>\n'}, {'answer_id': 5747603, 'author': 'MatthiasS', 'author_id': 163725, 'author_profile': 'https://Stackoverflow.com/users/163725', 'pm_score': 4, 'selected': False, 'text': '<p>Assuming that your editor defaults to vi/vim, you can exit the commit message editor by typing:</p>\n\n<pre><code>:x\n</code></pre>\n\n<p>which will save and exit the commit message file. Then you\'ll go back to the normal git command section.</p>\n\n<p><em>More vi commands:<br>\n<a href="http://www.lagmonster.org/docs/vi.html" rel="nofollow noreferrer">http://www.lagmonster.org/docs/vi.html</a></em></p>\n'}, {'answer_id': 10051167, 'author': 'JiuJitsuCoder', 'author_id': 1318525, 'author_profile': 'https://Stackoverflow.com/users/1318525', 'pm_score': 2, 'selected': False, 'text': '<p>For those of you using OS X I found this command to work well:<br>\n<code>git config --global core.editor "open -t -W"</code></p>\n\n<p>which will force git to open the default text editor (textedit in my case) and then wait for you to exit the application. Keep in mind that you need to "Save" and then "Quit" textedit before the commit will go through. There are a few other commands you can play around with as detailed on this page:</p>\n\n<p><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/open.1.html" rel="nofollow noreferrer" title="Apple Developer Library - Open Command">Apple Developer Library - Open Command</a></p>\n\n<p>You can also try <code>git config --global core.editor "open -e -W"</code> if you want git to always open textedit regardless of what the default editor is.</p>\n'}, {'answer_id': 15530614, 'author': 'nothankyou', 'author_id': 1388224, 'author_profile': 'https://Stackoverflow.com/users/1388224', 'pm_score': 3, 'selected': False, 'text': '<p>When you create a new commit,  git fires up a text editor and writes some stuff into it.</p>\n\n<p><strong>Using this text editor, the intention is for you to write the commit message that will be associated with your feshly created commit.</strong></p>\n\n<p><strong>After you have finished doing so, save and exit the text editor.  Git will use what you\'ve written as the commit message.</strong></p>\n\n<p>The commit message has a particular structure, described as follows: </p>\n\n<p>The first line of the commit message is used as the message header (or title).  The preffered length of the commit header is less than 40 characters, as this is the number of characters that github displays on the Commits tab of a given repository before truncating it, which some people find irritating.</p>\n\n<p>When composing the header, using a capitalized, present tense verb for the first word is common practice, though not at all required.  </p>\n\n<p>One newline delineates the header and body of the message.</p>\n\n<p>The body can consist whatever you like.  An overview of the changes introduced by your commit is reasonable.  Some third party applications use info included the body of commit messages to set off various kinds of hooks (I\'m thinking Gerrit and Pivotal Tracker, to name two).  </p>\n\n<p>Here\'s a short and sweet example.  A leading <code>#</code> denotes a comment.</p>\n\n<pre><code>Gitignore index.pyc\n\nIgnore gunicorn generated binary file\n# Please enter the commit message for your changes. Lines starting\n# with \'#\' will be ignored, and an empty message aborts the commit.\n# On branch dev\n# Your branch is ahead of \'origin/dev\' by 10 commits.\n#   (use "git push" to publish your local commits)\n#\n# Changes to be committed:\n#   (use "git reset HEAD &lt;file&gt;..." to unstage)\n#\n#   modified:   .gitignore\n#\n</code></pre>\n\n<p><a href="https://gist.github.com/matthewhudson/1475276">Here</a> one Mr. Torvalds opines on what makes a good commit.</p>\n\n<p>And <a href="http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html">here</a> Tpope does likewise.</p>\n\n<p>As stated in several other answers, changing the default editor is a one-liner on the command line.  </p>\n\n<p>For my preference: </p>\n\n<pre><code>git config --global core.editor "vim"\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/60278', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']