Staging and Committing

View saved

Check the working tree

git status shows untracked files, staged changes, and unstaged edits. Run it often.

git status

Stage selected files

Staging chooses what belongs in the next commit. You can stage one file or everything in the folder.

git add README.md
git add .
git status

Create a commit

A commit message should explain why the change exists. The -m flag supplies a short message on the command line.

git commit -m "Add project README"

Build a useful habit

  • Make small commits that do one job
  • Write messages in the imperative mood: Fix typo in title
  • Run git status before and after each commit
  • Do not stage secrets such as passwords or API keys

Comments

One comment per signed-in account. Comments are saved with this page’s URL.