Git Commit

Git Commit

Adding commits keep track of our progress and changes as we work. Git considers each commit change point or "save point". It is a point in the project you can go back to if you find a bug, or want to make a change.

When we commit, we should always include a message. By adding clear messages to each commit, it is easy for yourself (and others) to see what has changed and when.

$ git commit -m "First release of Hello World!"
[master (root-commit) 221ec6e] First release of Hello World!
 3 files changed, 26 insertions(+)
 create mode 100644 README.md
 create mode 100644 bluestyle.css
 create mode 100644 index.html

The commit command performs a commit, and the -m "message" adds a message.

The Staging Environment has been committed to our repo, with the message: "First release of Hello World!"


Git Commit Log

To view the history of commits for a repository, you can use the log command:

$ git log
commit 09f4acd3f8836b7f6fc44ad9e012f82faf861803 (HEAD -> master)
Author: w3schools-test
Date: Fri Mar 26 09:35:54 2021 +0100

 Updated index.html with a new line

commit 221ec6e10aeedbfd02b85264087cd9adc18e4b26
Author: Kevin
Date: Saturday July 02 09:13:07 2022 +0100

 First release of Hello World!


Checking The Status

At the end, let us check the status

$ git status
 # On branch master nothing to commit (working directory clean)

The working directory is clean, you can continue working.