Status, Log & .gitignore
Seeing What's Going On
| Command | Shows |
|---|---|
git status | What's changed, staged, or untracked |
git log | Commit history |
git log --oneline | Compact one-line-per-commit history |
git diff | Line-by-line unstaged changes |
git diff --staged | What's staged for the next commit |
$ git log --oneline
a1b2c3d Add readme
9f8e7d6 Initial commit
Tip: git status is your best friend - run it constantly. It literally tells you what to do next (how to stage, unstage, or discard).
.gitignore - keep junk out
Some files should never be committed: secrets, build artifacts, dependencies. List them in a .gitignore file and Git pretends they don't exist.
# .gitignore
node_modules/
.env
*.log
dist/
Danger: Never commit secrets (.env, API keys, private keys). Once pushed, they're in history forever - even deleting them later doesn't remove them from past commits. Add them to.gitignorebefore the first commit.