Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Commit Messages | Introduction to Git
Git Essentials
course content

Contenido del Curso

Git Essentials

Git Essentials

1. Introduction to Git
2. More Advanced Interaction
3. Undoing Changes
4. Working with Branches in Git

bookCommit Messages

Why Commit Messages Matter

Commit messages play a crucial role in understanding the history of a project. Well-crafted commit messages make it easier for collaborators, future developers, and even yourself to comprehend the purpose and context of each change. A clear commit history facilitates collaboration, debugging, and the process of identifying specific changes in a project's timeline.

Anatomy of a Good Commit Message

1. Conciseness and Clarity

A commit message should be concise and to the point. It should clearly convey the purpose of the commit in a single line. Avoid ambiguity and provide enough information to understand the change without having to look at the actual code.

2. Separate Subject from Body

If more details are needed, separate the subject from the body of the commit message with a blank line. The subject should summarize the change, and the body can provide additional context, reasons for the change, and any relevant information.

Let’s take a look at an example of such commit message:

In this case, however, we will simply run the git commit command without the -m flag:

The default text editor for Git will be opened, where you can write a detailed commit message. You should then save it and exit the text editor appropriately.

Let's make another commit in our repository:

Here is the command that we used to modify our text file:

The commit message as follows:

If you cannot edit the file, press the i key. This ensures that you enter the edit mode. Once again, to save changes and exit Vim, press the Escape key and two capital Z letters.

Note

If you have a different default text editor for the terminal (other than Vim), and encounter any difficulties, you can easily find how to save changes and exit it on the internet.

3. Use Imperative Mood

Write commit messages in the imperative mood, which gives a sense of direction for the change. Start the subject with a verb, such as "Fix," "Add," or "Update."

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 10
We're sorry to hear that something went wrong. What happened?
some-alt