Learn it by doing it
How to set up a repo with Claude Code
Watch it done first, then do it yourself in the lessons below. Pause the walkthrough at any step and try it on your own computer.
Watch it done: branch, review, commit and open a pull request
Step 1 of 7
Ask for a branch before the work starts, never after. Plain words are enough.
- Ask for a branch before the work starts, never after. Plain words are enough. Type: create a new branch called fix/due-date-sort. Claude runs the git commands to create the branch.
- Once Claude has made the fix, ask what changed before you do anything else. Type: what files have I changed?. Claude checks git and lists the changed files.
- Read the actual changes before you commit them. Type: /diff. A view of your working tree opens, listing each changed file with its added and removed line counts, including the edits Claude has made so far.
- Prefer git itself? Start a line with ! to run a shell command directly from the prompt. Type: ! git status. The command runs straight away without Claude needing to approve it. Its output lands in the conversation and Claude responds to it.
- Commit after each step that works. Small commits are easy to read and easy to undo. Type: commit my changes with a descriptive message. Claude writes the message and commits. By default the commit carries a Co-Authored-By line, which the attribution setting can change or hide.
- Share the change. Read the description Claude wrote before anyone else does, because it goes out under your name. Type: create a pr. With the GitHub CLI, gh, installed and signed in, Claude opens the pull request with it.
- Undo a bad step from this session. For anything older, or changed by a script, use git. Type: /rewind. The rewind menu lists the prompts you sent. Pick one, then restore the code, the conversation, or both. Files changed only by shell commands are not restored.
Commands from the official Claude Code docs, checked 18 November 2026. Lines marked Note describe what happens and are not real output.
From the lesson Git with Claude Code.
Your path: 2 lessons
0 of 2 done · about 16 min
Do them in this order. Each one has you try it for real, then checks you can.
- 1Start
Level 4: Claude Code · 8 min
Git with Claude Code
Branches, commits, reviewing diffs, writing commit messages and pull requests with Claude Code, and undoing work with /rewind and git.
- 2Open
Level 4: Claude Code · 8 min
Connect MCP servers to Claude Code
Add an MCP server to Claude Code with claude mcp add, choose local, project or user scope, sign in with /mcp, keep tokens out of git and stay safe.
Next: Git with Claude Code. Start it now
These lessons are part of the Professional Diploma, unit D1: Building with Claude Code. See what it covers