Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - Do colours mean something in vi when I commit?

I'm using Git Bash on Windows and, when I run git commit, the vi editor opens to allow me writing a Commit note. I noticed that the first row of the text I write is yellow (although not all of it, only the first 30 or 40 characters), the second is white on a red background and from the 3rd onwards they are gray. Does this colour coding mean anything, or is it just some sort of weird glitch? I come from an SVN background, where Commit comment was pure text and I wasn't expecting this "rainbow". :)

Thanks in advance for the answers.

like image 315
Diego Avatar asked Aug 23 '12 01:08

Diego


People also ask

What does git commit flag do?

Add/Commit All By using the -a flag when committing you are telling Git to add all files that have been modified and then commit them. This runs into issues with new files, though. Since the -a flag only adds modified files it will not add new files or deleted files.

Should I use past tense in git commit?

It is up to you. Just use the commit message as you wish. But it is easier if you are not switching between times and languages. And if you develop in a team - it should be discussed and set fixed.

Which flag is used with git commit command?

Perhaps the most common flag used with git commit is the -m flag. The -m flag, which stands for message, is used to add a commit message to a commit. When you use the git commit command without the -m flag, a text editor will be opened in which you can write a message, as we discussed earlier.


1 Answers

Vi is giving you a hint about "properly" formatting your commit message.

While there is no specific enforcement of one message style w.r.t. another, "traditionally" Git commit messages are structured this way:

  • A short title describing the changeset (usually less than 50-60 characters);
  • One blank line;
  • A more complete description of the commit, optionally divided in paragraphs with other blank lines.

The last paragraph is usually used for "metadata" entries, like Signed-off-by:.

So, in your case, Vi is probably warning you that the first line is a a little longer than usual and that you did not leave a blank line after it (I say "probably" because I do not use Vi, so I am not sure about it).

like image 166
Marco Leogrande Avatar answered Sep 21 '22 12:09

Marco Leogrande