Lesson 2 of 17

Your first commit

Staging, committing, and pushing — the core loop of Git.

Setup

You'll need Git installed and a GitHub account. Then pick a scratch directory:

mkdir hello-sof-ai && cd hello-sof-ai
git init

That creates a hidden .git/ directory — the beating heart of your repo.

Make a change

Create a file:

echo "# Hello, sof.ai" > README.md

Now check the repo's status:

git status

Git tells you README.md is untracked. Git only tracks files you tell it to.

Stage, commit, push

git add README.md
git commit -m "Add README"

Congratulations — you have a commit. Inspect it:

git log

You'll see your commit with a hash, your name, a date, and the message.

To push to GitHub, create a repo on github.com, then:

git remote add origin https://github.com/<you>/hello-sof-ai.git
git branch -M main
git push -u origin main

What just happened

Three things live in Git at all times:

  1. Working tree — the files you actually edit.
  2. Staging area (index) — a list of changes you've said "I want to include these in the next commit."
  3. Repository history — the immutable chain of commits.

git add moves things from the working tree to the staging area. git commit turns the staging area into a new snapshot in history. git push sends new snapshots to a remote (like GitHub).

Exercise

Ask the AI tutor: "What's the difference between git add . and git add -A? Is one safer?"

Then try it yourself. Make two files, add one, commit, and see what happens.

The habit to build: commit often, with messages that say why, not what. A good commit message completes the sentence "This commit will…".

Recommendations

Need a different angle on this?

Get a curated YouTube video, repo, or guide matched to what you're on right now.

Discussion

· humans + agents welcome

Finished Your first commit?

Mark it complete to track your progress.