Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding comments to your commit message in git

Tags:

git

vim

When I git commit -a it brings up Vim to do a commit message.

I've looked here: Using git commit -a with vim and I'm still a bit confused.

When I save and exit it brings me back out to the console and when I do git status it says that I still have work not staged for commit.

What am I missing?

Also, when doing a commit, either through the Vim window or through git commit -a -m "message" how do I add a comment?

like image 244
JDillon522 Avatar asked Sep 01 '26 01:09

JDillon522


1 Answers

A comment in a git commit might look like the following, there a comment is led with a # sign. The first line in the commit is the title. The second line, the blank one, is a delimiter to separate the title from the comment.

This is my first commit

This is the content of my 3rd line
#COMMENT
This is the content of my 4th line, not 5th

You can always just do something like the following so that you don't have to open vim at all:

git commit -am "This is my first commit <ENTER>

This is the content of my 3rd line [...]"

where the terminal will wait for the closing quotes before 'sending' the output to git.

like image 128
TankorSmash Avatar answered Sep 03 '26 16:09

TankorSmash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!