Your First Repository
A Git repository ("repo") is a project folder Git is tracking. Let's create one.
Initializing a repository
mkdir my-project
cd my-project
git init
git init creates a hidden .git folder, that's where Git stores the entire history of your project.
The three states of a file
| State | Meaning |
|---|---|
| Untracked / Modified | Changed on disk, not yet staged |
| Staged | Marked to be included in the next commit |
| Committed | Saved permanently in the project's history |
git status # see what's changed
git add app.js # stage a specific file
git add . # stage everything
git commit -m "Add app.js" # save the staged changes
Viewing history
git log
git log --oneline # one line per commit, easier to scan
TIP
Commit often, in small, focused chunks. "Add login form" is a much more useful commit message than "stuff".