Course contentsShow
← Software Engineering
Lesson 48 of 1,9332. Version Control with GitFree lesson

Committing Changes with 'git commit'

Creating commits with meaningful messages and understanding what a commit represents.

Committing Changes with 'git commit'

You'll learn how to save your staged changes as permanent snapshots in your Git repository and why good commit messages matter.

What Is a Commit?

A commit is like taking a photograph of your project at a specific moment in time. Once you've staged changes with git add (preparing them in the staging area), git commit captures those changes and stores them permanently in your repository's history. Each commit creates a checkpoint you can return to later if needed.

Think of commits like save points in a video game. Each save records exactly where you were and what you had accomplished. If something goes wrong later, you can reload that save point and continue from there.

Creating a Commit

To commit your staged changes, use:

git commit -m "Your message here"

The -m flag lets you add a message describing what you changed. For example:

git commit -m "Add user login form"

Why Commit Messages Matter

Your commit message is a note to your future self and your team. It answers: "What did this commit accomplish?"

Good messages are:

  • Clear: "Fix login button alignment"
  • Concise: One line describing the change
  • Meaningful: Explain what and why, not how

Poor messages like "fixed stuff" or "changes" waste everyone's time when reviewing history.

What Happens During a Commit

Git takes everything from your staging area and creates a permanent snapshot with a unique identifier. This snapshot includes who made the change, when, and your descriptive message. Your working directory and staging area remain unchanged—you can continue working.

Key Takeaway: A commit permanently saves staged changes as a snapshot in your repository's history, and clear commit messages help everyone understand what changed and why.