Commits

What

A Commit is a permanent snapshot of the staged changes in your repository at a specific point in time. Each commit represents a point on a timeline, recording exactly which files were modified, added, or deleted, and who made the change.

How

Once your changes are staged using git add, you save them to the repository history using the git commit command accompanied by a descriptive message:

# Commit staged changes with a descriptive message
git commit -m "Add initial project files and configuration"

If you attempt to run git commit without the -m flag, Git will open your default command-line text editor (e.g., Vim or Nano) to prompt you to write a detailed commit message.

Why

Commits are the building blocks of version control. By dividing your development process into logical, well-described commits, you create a readable historical log. If a bug is introduced later, you can easily trace it back to a specific commit, compare changes between any two points in time, or safely restore your project to a previous snapshot without losing other work.

Summary

Use git commit -m "message" to permanently save your staged changes as a unique, historical snapshot in your repository.