Staging and Committing
Stage changes
git add file.txt # Stage one file
git add file1.txt file2.txt
git add . # Stage everything in current directory
git add -A # Stage everything in the whole repo
Staging means "mark this change to be included in the next commit".
Commit staged changes
git commit -m "Add initial project files"
A commit is a permanent snapshot with a message explaining why, not just what.
Stage and commit in one step (tracked files only)
git commit -am "Fix typo in README"
Note: -a only works for files Git already tracks — new files still need git add first.
Undo staging
git restore --staged file.txt # Unstage, keep changes
Good commit messages
# Bad
git commit -m "stuff"
# Good
git commit -m "Fix login redirect bug for expired sessions"