Your first commit
Save a snapshot of your project
A commit is one save point for your project. In this lesson you'll turn a folder into a Git repository and save your first snapshot.
What is a commit?
Imagine taking a photo of your desk every evening. If something goes missing later, you look at the photos and see exactly how things were. A commit is that photo, but for your project files.
- It stores how every file looked at that moment
- It has a short message, like "Add login page"
- It has your name and the date
Step 1: Create a repository
Make a practice folder and open it in the terminal. You can also use any folder from earlier lessons, like your project notes.
mkdir my-first-repo
cd my-first-repo
git initLet's break this down:
mkdirmakes a new foldercdmoves you into that foldergit inittells Git to start watching this folder. It creates a hidden.gitfolder that stores the history
Now create a small file. Open the folder in VS Code and add a README.md with one line, like # My first repo.
Step 2: Check the status
git status is your "what's going on?" command. Use it often.
git statusUntracked files:
README.md
nothing added to commit but untracked files present"Untracked" means Git sees the file but is not saving it yet.
Step 3: Stage and commit
First, put your changes in the staging basket. Then save them with a message.
git add .
git commit -m "Add README with project title"git add .stages every changed file in this folder. The dot means "everything here"git commit -m "..."saves the snapshot with your message
Run git status again. It should say nothing to commit, working tree clean. That means everything is saved.
Writing good commit messages
Your messages are notes to your future self. In two weeks, you'll want to find "the version before the cart broke". Good messages make that easy.
- Start with a verb: Add, Fix, Update, Remove
- Say what changed, not how you felt
- Keep it under about 60 characters
Add habit list to home page
Fix streak count resetting at midnight
Update button colors to match brandLet AI make the commit for you
AI coding tools can run Git for you. In Claude Code, you can simply ask:
Look at what changed since the last commit.
Stage everything and commit it with a short, clear message
that starts with a verb.Browser builders like Lovable also save commits for you when you connect GitHub. You'll see this when you use an AI app builder.
Common mistakes
- Wrong:
git commit -m "stuff". Right:git commit -m "Add dark mode toggle". - Wrong: running
git initin your whole home folder. Right: run it inside one project folder. - Wrong: forgetting
git add, then wondering why the commit is empty. Right: rungit statusto check what is staged. - Wrong: one giant commit after a full day of work. Right: small commits after each working step.
Practice
Try these exercises to lock in what you just learned.
What's next?
You have a save point. Next, in History and undo, you'll learn how to look back at your commits and go back when something breaks.