Vibe Coding Version Control - GitHub Setup & Usage Guide
A practical guide to using Git in vibe coding. Covers everything from installing GitHub Desktop and creating repositories to committing, pushing, and rolling back in Claude Code and Codex — a hands-on workflow for solo vibe coders.
In vibe coding, AI creates and modifies code at an incredible speed. But what happens when the AI makes unintended changes, or a perfectly working feature suddenly breaks? This is where version control comes in. Version control records the history of code changes and serves as a safety net that lets you revert to any previous state at any time.
This guide covers how to use Git in Claude Code and Codex—with specific instructions for CLI, IDE, desktop app, and web environments.
Why Version Control Matters More in Vibe Coding
Version control has always been essential in development, but it's even more critical in vibe coding.
First, AI modifies multiple files simultaneously. Unlike manually editing one file at a time, when AI changes 10 files at once and something breaks, it's hard to identify which change caused the issue. Frequent commits let you pinpoint and roll back to specific moments in time.
Second, AI's judgment isn't always correct. AI might say "this is better code" and change existing logic, only for you to discover later that the original code was right. With Git, you can use git diff to see what changed and revert if needed.
Third, experimentation becomes risk-free. Create a branch, ask AI to attempt a bold refactoring, and if you don't like the result, simply delete the branch. Your main code stays safe.
Key Commands Reference
| Command | What It Does | Gaming Analogy |
|---|---|---|
| git clone | Copy a remote repository to your computer | Downloading a game |
| git add | Stage changed files for commit | Adding items to inventory |
| git commit | Record changes to the repository | Save game |
| git push | Upload local commits to remote repository | Cloud save |
| git pull | Download latest changes from remote | Downloading update patch |
| git branch | Create an independent workspace | New save slot |
| git merge | Combine branches together | Merging save slots |
| git diff | Compare changes | Checking change log |
| git revert | Undo a specific commit | Rollback |
The four commands you'll use most in vibe coding are commit (save), push (upload), pull (sync), and branch (separate workspaces). For a more detailed explanation of each concept, check out our version control systems article.
Getting Started with GitHub
We recommend installing GitHub Desktop first. GitHub Desktop is an official desktop app that lets you commit, branch, push, and more through a GUI—no Git commands needed. It also includes Git, so there's no need to install Git separately.
Step 1: Sign up for GitHub — Create a free account at github.com.
Step 2: Create a repository — After signing in, click the '+' button in the top right → 'New Repository'. Enter a repository name, make sure to check 'Add a README file', then click 'Create repository'. Checking README creates an initial commit automatically, so you can clone right away.
Step 3: Clone — Open GitHub Desktop, select 'Clone a repository', and choose the repo you just created. It will be copied to your computer. You can also use the terminal:
# Clone via terminal
git clone https://github.com/your-username/your-repo.git
cd your-repo
Step 4: Connect your vibe coding tool
Claude Code users: Run claude in the cloned folder, then type /install-github-app to automatically set up GitHub integration.
Codex users: Run codex in the cloned folder. Connect your GitHub account in the Codex app and you're ready to go.
Using Git in Claude Code
Claude Code supports Git operations across all its environments: CLI, VS Code, JetBrains IDEs, desktop app, and web. Here's how each one works.
Claude Code CLI
In the Claude Code CLI, you can request Git operations in natural language. Simply run claude in your terminal and ask.
# Launch Claude Code
cd my-project
claude
# Request Git operations in natural language
> commit my changes
> create a PR
> show me the diff with main branch
> fix this bug and commit
Claude Code executes Git commands like git add, git commit, and git push directly. The important thing is that it asks for user approval before executing any command. AI won't push code without your permission.
If you want to commit, push, and create a PR all at once, you can use the built-in skill.
# Commit + Push + PR in one step
> /commit-push-pr
# Or step by step
> summarize my changes # Check what changed first
> commit with a good message # Commit
> create a pr # Create Pull Request
Here are particularly useful Git-related features in Claude Code CLI.
Plan Mode: A read-only mode toggled with Shift+Tab. It only analyzes code without making changes, so you can safely explore your codebase before making modifications. The recommended approach is to plan first, then switch back to normal mode to execute.
Git Worktree: A Git feature that lets you check out multiple branches simultaneously from the same repository. In Claude Code, you can run separate sessions in each worktree to work in parallel.
# Parallel work with Worktrees
git worktree add ../my-project-feature-a -b feature-a
cd ../my-project-feature-a
claude # Work independently on this branch
# In another terminal
cd ../my-project
claude # Separate work on main branch
Claude Code IDE / Desktop
| Platform | Key Git Features |
|---|---|
| Desktop App | Built-in diff review, visually verify AI-made changes |
| VS Code | Inline diff display, accept/reject changes in editor |
The Claude Code desktop app specializes in diff review, letting you visually verify what the AI changed before committing.
In VS Code, changes appear as inline diffs. You can accept or reject changes right in the editor, eliminating the need to switch between terminal and editor.
Using Git in Codex
Codex also supports Git operations across all its environments: CLI, VS Code, desktop app, and web (Codex Cloud). Let's compare how it differs from Claude Code.
Codex CLI
The first concept to understand when using Git in Codex CLI is approval modes. This setting determines how much the AI can do automatically.
| Mode | File Read | File Edit | Command Execution | Best For |
|---|---|---|---|---|
| Auto (default) | Auto | Auto | Auto within working dir | Everyday work, trusted projects |
| Read-only | Auto | Requires approval | Requires approval | Code analysis and review only |
| Full Access | Auto | Auto | Full auto | Fully trusted environments only |
In Auto mode (the default), Codex can freely read and edit files within the working directory. Git commands also run automatically within the directory. However, commands that access outside the directory or require network access (like git push) will ask for user confirmation.
You can switch modes during a session by typing /permissions.
# Launch Codex
cd my-project
codex
# Request Git operations in natural language
> commit my changes
> review my recent commit
> create a feature-login branch and start working
A particularly powerful Git feature in Codex CLI is the /review command. It provides AI code review before committing, where a separate reviewer agent analyzes your changes and provides prioritized feedback.
# After typing /review, you'll see options:
# 1. Review against a base branch → Compare branches
# 2. Review uncommitted changes → Review unstaged/staged changes
# 3. Review a commit → Review a specific commit
# 4. Custom review instructions → Custom review (e.g., "focus on security")
> /review
Codex App / IDE
| Platform | Key Git Features |
|---|---|
| Desktop App | Built-in Review for pre-commit code review |
| VS Code | Slash commands (/review, etc.), in-editor diff display |
The Codex desktop app has a built-in Review feature that lets you check code changes right before committing.
In the VS Code extension, slash commands (/review, /fork, etc.) provide quick access to Git-related workflows.
Practical Workflow
The daily workflow for a solo vibe coder is simple. Ask AI to modify code, save it, and upload it. Just remember these three steps.
| Step | Action | Claude Code | Codex |
|---|---|---|---|
| 1. Code | Write code with AI | Natural language requests | Natural language requests |
| 2. Commit | Save changes (save game) | "commit my changes" | "commit my changes" |
| 3. Push | Upload to GitHub (cloud save) | "push" | "push" |
AI tools make this even simpler. In Claude Code, a single /commit-push-pr handles everything from commit to push. In Codex Auto mode, just say "commit and push" and it takes care of the rest.
The key is keeping work units small. Rather than asking AI to tackle a large task all at once, break it into smaller pieces and commit each one. This makes it much easier to identify the cause when something goes wrong.
When Things Go Wrong: Pull and Rollback
These are the commands you need when AI breaks your code or you need to sync changes from another device.
| Situation | Command | In AI Tools |
|---|---|---|
| Get latest code from another device | git pull | "pull" |
| Undo the last commit | git revert HEAD | "revert the last commit" |
| Go back to a specific commit | git revert | "revert to 3 commits ago" |
| Discard all uncommitted changes | git checkout -- . | "discard all changes" |
git revert is safe because it records the undo as a new commit, preserving the full history so you can see what was rolled back later. git reset, on the other hand, deletes history itself—use it cautiously and only when working alone.
The more frequently you commit, the more rollback points you have, making recovery much easier. It's the same principle as creating frequent save points in a game.
Should You Let AI Write Commit Messages?
Absolutely. Both Claude Code and Codex analyze your changes and automatically generate appropriate commit messages.
# Claude Code
> commit my changes
# → Generates message like "Fix null pointer exception in user authentication flow"
# → Commits after user approval
# Codex
> commit
# → Analyzes changes and suggests a message
# → Auto-executes or waits based on approval mode
AI-generated commit messages are generally accurate, but a final review is recommended. Especially for business logic changes or critical fixes, it's important to clearly state why the change was made in the commit message. AI excels at explaining what changed, but sometimes the why needs human input.
.gitignore Configuration
.gitignore is a configuration file that specifies which files Git should not track. There are items that need special attention in a vibe coding environment.
# Environment variables (API keys, passwords)
.env
.env.local
# Dependencies (large, re-installable)
node_modules/
venv/
# Build output
dist/
build/
# OS files
.DS_Store
Thumbs.db
# IDE settings (personal environment)
.vscode/
.idea/
The .env file (API keys, passwords, etc.) should never be committed. When you ask AI tools to "commit," both Claude Code and Codex will warn you about sensitive files, but pre-registering them in .gitignore is the safest approach.
When creating a new repository, selecting a template on GitHub auto-generates a .gitignore suited to your project type. Alternatively, ask your AI tool to "create a .gitignore for this project."
Conclusion
Version control is the safety net of vibe coding. No matter how smart AI gets, you'll feel uneasy if you can't undo changes. With GitHub, you can always roll back to a previous state, experiment freely, and keep your main code safe.
Whether you use Claude Code or Codex, the core workflow is the same: create a branch, work on it, commit, push, and send a PR. AI tools handle this process through natural language, so you don't need to memorize Git commands. What matters is "commit often, use branches, and don't be afraid to experiment."