We can use the git commit
command to save any changes we make to the local repository. We use the git commit
command with the -m
option 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.
Note: It is a good practice to keep the length of the “message” below 50 characters.
To change the most recent commit message, use the git commit
command with the --amend
option as shown below:
git commit --amend -m "New message"
Consider the code snippet below, where we create a git commit with a message.
git rm file1.txt git commit -m "file1.txt removed" git commit --amend -m "file1.txt deleted from working directory"
file1.txt
from the working directory using rm
command. We save the changes in the removed file to the local repository using the git commit with option -m
in line 3.git commit
command with the amend
option in line 5 to change the commit message.RELATED TAGS
CONTRIBUTOR
View all Courses