Skip to main content

Git Basics for Claude Code

Module: Git Integration | Lesson: 1 of 4 | Time: ~10 minutes

What You Will Learn

  • What Git is and why version control matters
  • How to initialize a repository through Claude
  • How to add files and create commits

Prerequisites

What Is Git?

Imagine you are writing an essay. You finish the first draft, then make some changes. Later, you make more changes. Then you realize the changes you made yesterday were better than today's, and you want to go back — but you already saved over the old version.

Git solves this problem. It is an undo history for your entire project. Every time you save a snapshot (called a "commit"), Git remembers exactly what every file looked like at that moment. You can go back to any snapshot at any time, compare different versions, and even work on multiple versions simultaneously.

Git is the most widely used version control system in the world. Nearly every software project — from tiny personal websites to massive applications like Windows and Android — uses Git.

You do not need to be a programmer

Git is useful for any project with files that change over time. If you are using Claude Code to build anything — a website, a script, a configuration — Git helps you keep track of what changed and when. And the best part: Claude can handle the Git commands for you.


Key Concepts

Before we dive in, here are the four concepts you need to understand. We will keep these simple.

Repository (Repo)

A repository is a project folder that Git is tracking. When you "initialize a Git repo," you are telling Git: "Start watching this folder and everything in it."

From the outside, a Git repository looks like a normal folder. The only difference is that it contains a hidden .git folder where Git stores all its history.

Commit

A commit is a snapshot of your project at a specific moment. Think of it like pressing "Save" in a video game — you can always come back to that exact point.

Each commit includes:

  • A snapshot of all tracked files
  • A message describing what changed (for example, "Add contact form to homepage")
  • A timestamp and author
  • A link to the previous commit

Branch

A branch is a separate line of development. Imagine you have a working website and you want to try adding a new feature. Instead of changing the live version directly, you create a branch — a copy where you can experiment safely. If the experiment works, you merge it back. If it fails, you just delete the branch.

The main branch is usually called main (or sometimes master in older projects).

Merge

Merging combines changes from one branch into another. When your feature branch is ready, you merge it into the main branch, bringing all your changes together.


Setting Up Git on Windows

Before using Git with Claude Code, you need Git installed on your system.

Check If Git Is Already Installed

Open your terminal (Command Prompt, PowerShell, or Windows Terminal) and type:

git --version

If you see a version number (like git version 2.43.0.windows.1), Git is already installed. Skip to the next section.

Install Git

If Git is not installed:

  1. Go to https://git-scm.com/download/win.
  2. Download the installer for your version of Windows.
  3. Run the installer. The default settings are fine for most people — just click "Next" through the wizard.
  4. When the installer asks about the default editor, you can choose whatever you prefer (VS Code is a good choice, or just leave the default).
  5. After installation, close and reopen your terminal, then run git --version to confirm it worked.

Configure Your Identity

Git needs to know who you are (for commit history). Open your terminal and run these two commands, replacing the name and email with your own:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
This is a one-time setup

You only need to do this once per computer. Git will remember your identity for all future projects.


Initializing a Repository Through Claude

Now let us use Claude Code to work with Git. Start Claude Code in a project folder and ask it to set up Git:

You: Initialize a Git repository in this folder

Claude will run git init for you and confirm that the repository was created. You should see something like:

Initialized empty Git repository in C:/Users/you/my-project/.git/

Your project folder is now a Git repository. Git is watching it, but it has not saved any snapshots yet.


Checking the Status

To see what Git knows about your files, ask Claude:

You: What is the Git status of this project?

Claude will run git status and show you something like:

On branch main

No commits yet

Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
style.css
app.js

nothing added to commit but untracked files present

This tells you:

  • You are on the main branch.
  • There are no commits yet (no snapshots saved).
  • Git sees three files but is not tracking them yet — they are untracked.

Adding Files and Creating Your First Commit

To save a snapshot, you need two steps:

Step 1: Stage Files (Tell Git What to Include)

Staging is like putting items in a box before shipping. You choose which files to include in the next snapshot.

You: Add all files to Git staging

Claude will run git add . (the dot means "everything in this folder").

Step 2: Commit (Save the Snapshot)

Now save the snapshot with a descriptive message:

You: Commit these files with the message "Initial project setup with HTML, CSS, and JS"

Claude will run git commit -m "Initial project setup with HTML, CSS, and JS" and confirm the commit was created.

Write meaningful commit messages

A good commit message says what changed and why. Compare these:

  • Bad: "update files"
  • Bad: "stuff"
  • Good: "Add contact form with email validation"
  • Good: "Fix navigation menu not displaying on mobile"

You do not need to worry too much about this now — Claude writes good commit messages automatically, as you will see in the next lesson.


Viewing Commit History

To see your project's history, ask Claude:

You: Show me the Git log

Claude will run git log and show you each commit with its message, author, date, and a unique identifier (called a hash).

commit a1b2c3d (HEAD -> main)
Author: Your Name <you@example.com>
Date: Wed Apr 1 10:30:00 2026

Initial project setup with HTML, CSS, and JS

As you make more commits, this log grows — giving you a complete history of every change.


The Git Workflow in Claude Code

Here is the basic workflow you will use repeatedly:

1. Make changes to your files
└── Ask Claude to create, edit, or delete files

2. Check what changed
└── "What's the Git status?" or "Show me what changed"

3. Stage the changes
└── "Add these changes to Git staging"

4. Commit
└── "Commit with a message describing what we did"

5. Repeat

The great thing about Claude Code is that you can do all of this in natural language. You never need to memorize Git commands — just describe what you want.


Try It Yourself

  1. Create a new project folder and start Claude Code:

    mkdir git-practice
    cd git-practice
    claude
  2. Ask Claude to initialize Git:

    Initialize a Git repository here
  3. Ask Claude to create a file:

    Create a file called hello.txt that says "Hello, Git!"
  4. Check the status:

    What does git status show?
  5. Make your first commit:

    Commit all files with the message "Add hello.txt greeting file"
  6. Make a change — ask Claude to edit the file:

    Add a second line to hello.txt that says "This is my first Git project."
  7. Check the status again:

    What changed since the last commit?
  8. Commit the change:

    Commit this change with a message about adding the second line
  9. View the history:

    Show me the Git log

    You should see two commits — your complete project history.


What You Learned

  • Git is an undo history for your entire project — it tracks every change you make.
  • A repository is a project folder tracked by Git. A commit is a saved snapshot.
  • A branch is a separate line of work. Merging combines branches together.
  • You need to install Git and configure your name and email once per computer.
  • Through Claude Code, you can initialize repos, check status, stage files, and commit — all in natural language.
  • Good commit messages describe what changed and why.

Help Us Improve

How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.

Give Feedback →

Next Up

Next: Committing with Claude