Stuck on Git message

I'm trying to learn git. After doing the initial add . I come to a
message. Do I add my comment as a comment with # before my line, or
what? And how to I get out of there?

I've been trying to find a good tutorial but I can't find any that
explains this issue, so I get stuck. Are there any good tutorials about
git that really explains it without leaving out important parts like
this?

I'm guessing you typed "git ci" ? If so that will open up whatever editor is defined in the EDITOR environment variable. Write your message (without preceeding #'s) and then save.

Or, do it this way:

git ci -m "this is my commit message"

-philip

Pål Bergström wrote:

I'm trying to learn git. After doing the initial add . I come to a
message. Do I add my comment as a comment with # before my line, or
what? And how to I get out of there?

I've been trying to find a good tutorial but I can't find any that
explains this issue, so I get stuck. Are there any good tutorials about
git that really explains it without leaving out important parts like
this?

The sequence is.

# git add <file or directory tree>
# git commit -m <comment here> | Insert as first line in message file
that editor opens.

If this is a local repository then you are done. If cloned from a
remote master then you need to follow the local commit with a

# git push

To see the current status of the local vs. the remote repository

# git status

To update the local from the remote

# git pull

peepcode.com has an excellent pdf book on git for $9.00, a great value.
They also have a screencast on git ($9.00) as does railscasts.com (free)

I've got the same problem as this guy, and these comments aren't
helping.
When get prompts me to enter my commit message, it opens an editor,
and I for the life of me can't figure out how to close it.
How do I let it know that I'm done with my message?
Sorry for the n00b questions.

Close the editor.

If you're using "nano", it's Ctrl+X.

What's your output from

git config --get core.editor

?

Yeah, just close your editor and it will finish your message.

BTW, there is a great git tutorial on peepcode.com, the title is "Git
internals", it's quite big but I really understood git after reading
it, unfortunately it's not free... :frowning:

If you are using vi/Vim ... try pressing Esc and then :qw and hit
Enter. That should quit you out of there.

Which means it's time for me to read the documentation myself. :slight_smile:

http://www.kernel.org/pub/software/scm/git/docs/git-commit.html says:
"The editor used to edit the commit log message will be chosen from
the GIT_EDITOR environment variable, the core.editor configuration
variable, the VISUAL environment variable, or the EDITOR environment
variable (in that order)."

So if git config --get core.editor says nothing, then you need to find
the value of one of those environment variables to find out which
editor you're using.

If none of them are set, I have no idea what editor you're getting...
but you still need to save your changes to the file and exit the
editor.

Two probable default editors are nano and vi:
Nano exits with ctrl-x (and Y to question about saving changes).
vi saves and exits with :wq

If you don't need long commit messages you can avoid the editor entirely with:
git commit -m "your message here"

-Michael

Note: you may need to press ESC first if you are in edit mode.

Then it's vi I have.

You can change that with:

git config --global core.editor [your_favorite_editor]

or by setting GIT_EDITOR environment variable

unless you like vi, that is.

I learned to do:

git commit -a -v -m "message"

I understand -a and -m but not 100% on what -v does. I think it has to
do what it saves. With -v it only saves changed content. But not sure.

-v adds a bunch of text to the commit message, specifically a diff of
all the exact changes made by this commit.

Regards,
Michael