2.3 Working With Git
Course: Claude Code - Essentials Section: Core Workflows Video Length: 2-5 minutes Presenter: Daniel Treasure
Opening Hook
You've made changes to your code. Now it's time to save them to Git so your team can see what you did. Claude Code makes Git workflows conversational—you can ask Claude to commit, create branches, and even draft pull requests. This video shows the essentials: commits, branches, and PRs.
Key Talking Points
- Committing Your Changes
- Ask Claude: "commit my changes with a descriptive message"
- Claude analyzes the actual code changes and writes a meaningful commit message
- No guessing what to write; Claude explains what changed and why
-
Show on screen: Make a few edits, then ask Claude to commit. Show the auto-generated message.
-
Branches Keep Work Organized
- Create a branch for a feature or bugfix: "create a branch called feature/user-auth"
- Claude handles the Git commands; you just describe what you're doing
- Keeps main branch stable while you work
-
Show: Create a new branch and verify it's active
-
Creating Pull Requests
- After committing on a branch, ask: "create a pull request for this feature"
- Claude generates a description based on your actual code changes
- PRs let teammates review before merging
-
Show: Create a PR and highlight the auto-generated description
-
Understanding What Changed
- Ask: "what files have I changed?" or "summarize my changes"
- Claude shows you the diff between your branch and main
- Useful for understanding scope before committing
-
Show: Ask what changed, review the summary
-
Git Workflows Without Commands
- No need to type
git commit -morgit checkout -b - Just ask Claude in natural language
- Claude handles the Git CLI under the hood
- Show: Emphasize conversational workflow vs. command line
Demo Plan
Demo Project: Continue with the same project from 2.1-2.2
Setup: - Have a few code changes staged (use changes from 2.2, or make new ones) - Ensure Git is initialized in the project (git init should be done) - Open terminal with Claude Code session
On-Camera Sequence (2-3 minutes):
- Check Current Status
What files have I changed? - Claude shows the diff and lists modified files
-
~20 seconds
-
Create a Feature Branch
Create a new branch called feature/add-logging - Claude creates the branch and switches to it
- Show terminal confirming the branch is active
-
~20 seconds
-
Make Changes (if needed)
- If time permits, add a small feature or fix (e.g., "add a console.log to the main function")
- Approve Claude's changes
-
~30 seconds (optional, can skip if pressed for time)
-
Commit with Auto-Generated Message
Commit my changes with a descriptive message - Claude analyzes the changes and writes a commit message
- Show the message before final confirmation
- Approve and see the commit appear in the log
-
~30 seconds
-
Create a Pull Request
Create a pull request for this feature - Claude drafts the PR description
- Show the title and description (based on commit and code changes)
- Explain: this would open a PR on GitHub (if connected)
-
~30 seconds
-
(Optional) View Commit History
Show me the last 3 commits - Claude displays recent commits
- Confirms your new commit is there
- ~15 seconds
Code Examples & Commands
Ask Claude for Git operations:
What files have I changed?
Commit my changes with a descriptive message
Create a new branch called feature/user-profiles
Switch to the main branch
Create a pull request for this feature
Show me the last 5 commits
What's the diff between my branch and main?
Help me resolve merge conflicts
Summarize the changes I've made
Git fundamentals (for reference, but Claude handles these):
git status # Check changes
git add . # Stage changes
git commit -m "message" # Commit
git checkout -b branch-name # Create branch
git push origin branch-name # Push to remote
Gotchas & Tips
-
Commit Messages Matter – Claude's auto-generated messages are based on actual code changes. If the message doesn't fit, ask Claude to revise it before confirming.
-
Branches Require a Remote – To create PRs, you need a Git remote (GitHub, GitLab, etc.) configured. If not set up, Claude will note this.
-
Merge Conflicts Can Happen – If your branch conflicts with main, Claude can help analyze and resolve them. This is advanced (covered in troubleshooting if needed).
-
Commit Early, Often – Smaller, focused commits are easier to review and revert if needed. Encourage frequent commits.
-
PRs Are About Communication – Claude's PR description should tell reviewers what changed and why. Review it before opening.
-
You Can Always Amend – If you forgot to include a file in the last commit, ask Claude to amend it (though best practice is a new commit).
Lead-out
Your changes are now committed and in a PR, ready for team review. But what if something goes wrong? What if there's a bug to fix? That's where debugging comes in. In the next video, we'll show how Claude helps you find and fix bugs using error messages, logs, and strategic testing.
Reference Material
- Git Integration Guide: https://code.claude.com/docs/en/git
- Common Workflows - Creating PRs: https://code.claude.com/docs/en/common-workflows
- Quickstart - Using Git with Claude: https://code.claude.com/docs/en/quickstart
Relevant Articles & Posts
- Workflow Guide: Joe Njenga's "17 Best Claude Code Workflows" (Medium) – includes git workflows
- Best Practices: Lukasz Fryc's "15 Tips from Running 6 Projects" (DEV Community)
- Official Resource: Common Workflows - Claude Code Docs (https://code.claude.com/docs/en/common-workflows)
Additional Notes
- Emphasize that Claude handles Git commands; viewers don't need to know
git checkout -bsyntax - Show real, meaningful commit messages (not generic ones like "fix stuff")
- If PR creation fails due to no remote, explain briefly: need GitHub/GitLab configured
- Call out: good commit messages help teammates understand your changes
- Mention that in later sections, we'll show automation (hooks, MCP) to tie in git workflows