CodeAgeBy Sitezack
Git & CLI for Pros ⌨️Master Git on the command line0 XP
Chapter progress0/5

Lesson 1 of 5

init, add, commit

Git tracks your code across three areas: the working directory, the staging area, and the commit history. git init creates the repository.

git add puts files in staging; git commit -m freezes a snapshot into the history. We simulate these areas here with Python lists.

# git add app.py       -> staging.append("app.py")
# git commit -m "msg"  -> commits.append({"message": "msg", "files": list(staging)})

🎯 Exercise

Do a git add by appending "app.py" then "index.html" to staging. Then do a git commit: append to commits the dictionary {"message": "First commit", "files": list(staging)}, then clear staging. Print the number of commits.

PRO lesson

This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.

Discover PRO