Skip to content
Docs
தமிழ்
Esc
↑↓navigate↵open⌘Jpreview
On this page

Review, stage, and commit changes

Understand the working tree, staging area, diffs, commits, and pushes.

From edit to commit

Git gives you control over what goes into each commit. Think of the process as three places:

  1. The working tree contains the files you can edit.
  2. The staging area contains the exact changes selected for the next commit.
  3. The repository history contains committed snapshots.

This separation lets you review a change and choose what to save. A file can be changed in the working tree without being staged, and staged changes can be reviewed before they become a commit.

Inspect unstaged changes

git diff

git diff shows changes in the working tree that are not staged yet. Added lines are marked with +; removed lines are marked with -. It compares your current files with the staging area, so after staging a change, that part no longer appears in this ordinary diff.

Use the output to check that your edit says what you intended. git status gives a summary; git diff shows the actual line-by-line content.

Select what belongs in the next snapshot

git add <file>
git diff --staged

git add copies the current version of a file’s changes into the staging area. It does not create a commit. You can stage one file at a time to keep a commit focused. If you edit that file again after staging it, the newer edit is unstaged until you add it too.

git diff --staged compares the staging area with the latest commit. Read it before committing: this is the content Git will include in the next snapshot. If the staged version is wrong, edit the file and stage it again.

Save and publish the snapshot

git commit -m "Describe the finding"
git log --oneline
git push

git commit saves the staged changes as a new local commit. The message should briefly explain the purpose of the change. A commit does not upload anything; git log --oneline lets you confirm that it appears in local history, and git push publishes it to the branch’s configured remote.

If git status says a file is untracked or modified after the commit, inspect it before moving on. You may have another change that was not staged, or an unrelated file you should leave out of this commit.

Continue to branches and pull requests

Last updated on 9 அக்டோபர், 2026

Was this page helpful?