We can use the git commit
command to save our changes to the local repository. We use the git commit
command with the option -m
to create a git commit with a message.
Creating a git commit with a message is a good practice that helps describe and share our changes with other developers.
To create a git commit with a message, use the git commit
command with the -m
option as shown below:
git commit -m "message"
It is a good practice to keep the length of the
"message"
below 50 characters.
Most of the time, we do not work alone on our projects. Instead, there is a team of developers working together. We must create a git commit with a message to explain to other developers precisely what changes have been made in the project and why these changes were necessary.
Consider the code snippet below, where we create a git commit with a message.
git rm file1.txtgit commit -m "file1.txt removed from working directory"
The code snippet above removes the file file1.txt
from the working directory using rm
command. We save the changes of the removed file to the local repository using the git commit
with option -m
in line 3.
Free Resources