Committing the changes in git
Well, enough about staging. Let’s commit the staged changes to the repository.
When you previously used
git commit for committing the first
hello.html version to the repository, you included the
-m flag that gives a comment on the command line. The commit command allows interactively editing comments for the commit. And now, let’s see how it works.
If you omit the
-m flag from the command line, git will pop you into the editor of your choice from the list (in order of priority):
- GIT_EDITOR environment variable
- core.editor configuration setting
- VISUAL environment variable
- EDITOR environment variable
I have the EDITOR variable set to
emacsclient (available for Linux and Mac).
Let us commit now and check the status.
You will see the following in your editor:
| # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: hello.html #
On the first line, enter the comment: “Added h1 tag”. Save the file and exit the editor (to do it in default editor, press ESC and then type
:wq and hit Enter). You should see …
git commit Waiting for Emacs... [master 569aa96] Added h1 tag 1 files changed, 1 insertions(+), 1 deletions(-)
"Waiting for Emacs…" is obtained from the
emacsclient program sending the file to a running emacs program and waiting for it to be closed. The rest of the data is the standard commit messages.
Step2:Checking the status
At the end let us check the status.
You will see …
$ git status # On branch master nothing to commit (working directory clean)
The working directory is clean, you can continue working.