Loading lesson…
Git is a time machine for your code. Before we ship anything, let's learn the three commands that matter and what they actually do under the hood.
Git is a tool that takes snapshots of your project. Every snapshot is called a commit. If you break something, you can jump back to any old snapshot. This is also why AI coding is safer than it sounds — if the AI wrecks your code, git lets you rewind.
# Step 1: tell git who you are (one-time setup)
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
# Step 2: start a repo in your project folder
cd my-project
git init
# Step 3: write some code in a file, then:
git status # see what changed
git add hello.py # stage the file
git commit -m "first commit" # take the snapshot
# Step 4: check it worked
git log # shows your commit historySix commands. That's the minimum to put code under version control.| Command | What it does |
|---|---|
| git restore <file> | Throw away unstaged changes in one file |
| git reset HEAD~1 | Undo the most recent commit, keep the changes |
| git checkout <commit> | Travel back to an old commit (read-only) |
| git revert <commit> | Create a new commit that undoes an old one |
Once you commit locally, you can push your code to GitHub so it lives on the internet and can be shared. Create a repo on github.com, then run the two git remote commands GitHub shows you. You now have a portfolio link you can send anywhere.
Version control is the single most important tool in software engineering. AI did not change that.
— Linus Torvalds, paraphrased
The big idea: git gives you a safety net that makes experimenting with AI code fearless. Commit early, commit often, and you can always return to a working state.
15 questions · take it digitally for instant feedback at tendril.neural-forge.io/learn/quiz/end-coding-first-git-commit-builders
What is a commit in Git?
What does the command 'git status' tell you?
What is the purpose of the staging area in Git?
Which of these is an example of a good commit message?
Why should you create a commit before accepting a big change suggested by an AI coding assistant?
What does 'git restore <file>' do?
What does 'git reset HEAD~1' do?
What happens when you run 'git checkout <commit>'?
What does 'git revert <commit>' do?
What is a repository?
What does 'git push' do?
Why is it better to make many small commits rather than one giant commit?
After completing a working feature in your code, what should you do?
When you push your code to GitHub, what happens?
What is the main safety benefit of using Git when working with AI coding tools?