Your first commits

Five commands cover most of what you will do every day.

Committing is a two-step dance: you stage the changes you want (git add), then you commit them with a message.

git init                      # start tracking this folder
git status                    # what has changed?
git add index.html            # stage a file (or `git add .` for everything)
git commit -m "Add homepage"  # save the snapshot
git log --oneline             # see the history

The everyday loop. Run git status often, it always tells you what to do next.

Tip: Write commit messages as if finishing the sentence "This commit will...": "Add homepage", "Fix login bug". Future you will be grateful.

Quick check

You edited a file. Which command stages it for the next commit?

  1. git commit
  2. git add
  3. git log
  4. git init

Answer: git add. git add moves changes into the staging area. git commit then saves everything that is staged.