Git Add and Commit

Stage changes and record them as commits with clear messages.

  • git add
  • git commit
  • git amend
  • git stage
  • commit message

Git Add and Commit

Stage changes and record them as commits with clear messages.

Commands

CommandWhat it does
git status --shortShow changed/untracked files compactly
git add <file>Stage a specific file
git add -pStage hunks interactively
git commit -m "message"Commit staged changes with a message
git commit --amend --no-editFold new staged changes into the last commit
git restore --staged <file>Unstage a file, keep working-tree changes

Example

git status --short
git add -p
git commit -m "feat: add retry to payment client"

FAQ

What is the staging area?

An intermediate snapshot: add builds what the next commit records; uncommitted work-tree edits stay out.

When is --amend safe?

Only before pushing. Amending rewrites history, so never amend commits others already pulled.

よくある質問

What is the staging area?
An intermediate snapshot: add builds what the next commit records; uncommitted work-tree edits stay out.
When is --amend safe?
Only before pushing. Amending rewrites history, so never amend commits others already pulled.

Git