A guide to the Git Basics tutorial: the everyday cycle of git init, status, add, and commit, plus reviewing history with git log.
This tutorial teaches the core Git loop you will repeat thousands of times: start tracking, see what changed, choose what to record, and save it. Once this cycle is automatic, branching and the rest build naturally on top.
Starting a repository: git init
git init # start tracking the current folder
git init turns a plain folder into a Git repository by creating the hidden .git directory. You only do this once per project.
Seeing the state: git status
git status # what is changed, staged, or untracked
git status is the command you run most. It tells you which files are new, which are modified, and which are staged for the next commit. Run it whenever you are unsure what Git sees.
Staging changes: git add
git add index.html # stage one file
git add . # stage everything changed
git add moves changes into the staging area, the set of changes that will go into your next commit. Staging lets you record a focused, meaningful commit instead of everything at once.
Think of staging as packing a box. git add puts items in the box; git commit seals and labels it. You decide exactly what goes in.
Recording a commit: git commit
git commit -m "Add homepage layout"
git commit saves the staged changes as a snapshot with a message describing them. Good messages make the history readable later.
Reviewing history: git log
git log # full history
git log --oneline # compact, one line per commit
git log shows the commits you have made, newest first. It is how you read the story of a project.
The everyday rhythm is: edit, git status, git add, git commit. Run git status liberally; it removes all the guesswork.