git commit -m "<message>"
This command records your currently staged changes as a new commit in the repository's history and labels that snapshot with a descriptive message you provide.
It uses git commit to create a new commit object from whatever files are currently in the staging area (added with git add), and the -m (or --message) flag lets you pass a commit message directly on the command line instead of opening an editor; the <message> part is the human‑readable description of what changed, such as "Fix login bug" or "Add user profile page". This command only includes changes that have been staged, so any modified but unstaged files will not be part of the commit, which helps you control exactly what goes into each snapshot. If you omit -m <message>, git opens your default text editor so you can type a multi-line message instead.
You can tweak how this command behaves with additional flags: for example, adding -a as in git commit -am "Update API docs" stages all tracked modified files automatically before committing, while git commit --amend -m "Better commit message" rewrites the most recent commit with a new message (and optionally new content) instead of creating a brand new one. You can also use git commit -m "Initial commit" --no-verify to skip commit hooks, or git commit -m "WIP" --allow-empty to create a commit even if there are no staged changes.
Similar or complementary commands include git add <path> to select which changes will be part of the next commit, git status to see what is staged and what is not, and git log to inspect the commits you’ve already created; a common workflow is git add . followed by this command, and later git log --oneline to quickly review the resulting history. Another related variation is git commit without flags, which opens your editor for a detailed multi-line message (including a body explaining why the change was made), which is useful for more complex changes.
Examples:
git commit -m "Initial project setup"git commit -m "Fix broken registration form"git commit -m "Add user profile page"