Home / Git / Lesson 3

init, add, commit, status, log

Beginner 8 min read Lesson 3 of 5
mkdir lab && cd lab
git init
echo "# Lab" > README.md
git status
git add README.md
git commit -m "Add README"

git status tells you what is untracked, staged, or modified. git log --oneline lists commits. To unstage (keep the file): git restore --staged README.md on current Git; older docs say git reset HEAD FILE.

Messages

Write what changed and why, in the imperative: “Add CGPA formula comments”, not “fixed stuff”. One logical change per commit beats 40 files dumped as “update”.

Never git add . blindly if you have passwords, node_modules, or dataset dumps. Add a .gitignore first (Node’s standard one ignores node_modules and .env).