SyntaxStudy
Sign Up
Git git status, add, and commit
Git Beginner 9 min read

git status, add, and commit

The three most-used Git commands form your daily workflow: git status shows what has changed, git add stages changes for the next commit, and git commit saves a snapshot of the staged changes with a message.

Example
# Check the state of your working directory:
git status
# Shows: untracked files, modified files, staged changes

# Stage specific files:
git add index.html
git add src/app.js src/utils.js

# Stage all changes in the current directory:
git add .

# Commit staged changes with a message:
git commit -m "Add homepage layout"

# Stage and commit tracked files in one step (skips git add):
git commit -am "Fix typo in header"

# Write a multi-line commit message (opens your editor):
git commit

# Anatomy of a good commit message:
# ─────────────────────────────────────────
# feat: add user authentication endpoint   <- subject (≤72 chars)
#                                          <- blank line
# Implement JWT-based login route that     <- body (explains WHY)
# validates credentials against bcrypt
# hashes stored in the database.
# ─────────────────────────────────────────

# View commit history:
git log
git log --oneline           # compact format
git log --oneline --graph   # with branch graph