Skip to main content

Lesson 3 of 6 · 20 min

Your first repository: init, add, commit

The three commands behind every commit, practised on a tiny local project.

Make a practice project

mkdir foss-practice
cd foss-practice
echo "My first open source project" > README.md

Turn the folder into a repo

git init

Git now tracks this folder. Check the state of things:

git status

Git tells you README.md is untracked — it exists, but Git has not recorded it yet.

The three-step rhythm

Almost everything you do in Git is this rhythm:

  1. Edit files
  2. Stage what you want to snapshot: git add README.md
  3. Commit the snapshot: git commit -m "Add first README"

The staging area is a "next commit" basket: you choose exactly which changes go in. This lets you make clean commits — one logical change per commit — which open source maintainers love.

Practise the rhythm

echo "## Goals" >> README.md
echo "- Learn Git" >> README.md
git status
git add README.md
git commit -m "Add goals section to README"

See your history

git log --oneline

Each line is one snapshot with its message. This is the history that makes Git powerful.

Commit messages matter

Bad: stuff, fix, asdf. Good: Add install instructions to README. Write messages as if completing the sentence "This commit..." — future maintainers (including you) will thank you.

Next lesson: branches, where you can experiment without breaking anything.

Finished this track? FOSS Andhra certificates are issued for internships, workshops and events — check what you can earn next.