Version Control for the Vibe Coder (Part 1)¶
Imagine this: you open Cursor, ask it to build a feature in YOLO-mode, and let it rip. You flip back to Slack, reply to a few messages, check your emails, and return...
It's still running.
What the hell is going on? .sh
files appear, there's a fresh Makefile, and a mysterious .gitignore
. Anxiety creeps in. Should you interrupt it? Could you accidentally trash something critical?
Relax—you're not alone. This anxiety is common, especially among developers newer to powerful agents like Cursor's. Fortunately, Git is here to save the day.
Do these vibe coders use git?
Recently I asked twitter do these vibe coders use git?. The top responses were 'no' and 'not really'. I think this is a shame because git is a powerful tool that can help you manage your codebase more effectively.
1. Git Fundamentals¶
Git vs. GitHub: Understanding the Difference¶
Before diving deeper, let's clear up a common confusion: Git and GitHub are not the same thing.
- Git is a local version control system that runs on your computer
- Works completely offline
- Manages your code history
- Handles branching and merging
- Free and open-source
-
Can be used without any external services
-
GitHub is a web platform that hosts Git repositories
- Provides a place to store your Git repos online
- Enables collaboration with others
- Adds features like Issues, Pull Requests, and Actions
- One of many Git hosting services (others include GitLab, Bitbucket)
Most developers interact with both because:
- You clone (download) projects from GitHub using Git
- You make changes locally using Git commands
- You push those changes back to GitHub for sharing
Here's what this looks like in practice:
# Clone a project from GitHub
git clone https://github.com/username/project.git
# Make changes locally with Git
git checkout -b feature/new-idea
git add .
git commit -m "feat: add new feature"
# Share changes back to GitHub
git push origin feature/new-idea
Understanding Git's Core Concepts¶
Let's break down the essential Git concepts you need to know:
- Repository (Repo)
- A container for your project that tracks all changes
- Created with
git init
orgit clone
-
Contains all project history and metadata
-
Working Directory
- Your actual project files on disk
- Where you make changes before staging them
-
Use
git status
to see what's changed -
Staging Area (Index)
- A preparation area for your next commit
- Add files with
git add <file>
orgit add .
-
Review staged changes with
git diff --staged
-
Commits
- Permanent snapshots of your staged changes
- Each has a unique identifier (hash)
- Include author, date, and message
- Best practices:
Safety First: Git as Your Safety Net¶
When working with Git, here are some essential safety practices:
-
Create Save Points
-
What to Commit (and What Not to)
- Do Commit:
- Source code files
- Configuration files
- Documentation
- Tests
-
Don't Commit:
- API keys or secrets
- Large binary files
- Build artifacts
- Dependencies
-
Managing `.gitignore
2. Cursor + Git Integration¶
Why Git Matters Even More with Cursor¶
Cursor's AI agents can run long and make extensive code changes. While this might feel chaotic, using Git makes it powerful:
- Semantic boundaries: Commits mark logical checkpoints, not just arbitrary saves.
- Structured experiments: Cursor agents generate structured commits that are easier to review and manage.
- Reversible changes: Quickly revert any unwanted changes without losing valuable work.
Prompting Cursor to Use Git Effectively¶
When working with Cursor, you can guide its Git usage through clear prompts. Here are some effective prompting patterns:
-
Starting New Features
-
Incremental Development
-
Code Review Preparation
Handling Cursor's Generated Changes¶
When Cursor starts generating multiple files:
-
Interrupt Safely
-
Review Changes
-
Selective Commits
-
Recovery Options
Red Flags and Warning Signs¶
Watch out for these signs that Cursor might be doing too much:
- File Volume
- Creating more than 5-10 files at once
- Modifying files across many different directories
-
Generating large amounts of boilerplate
-
Change Patterns
- Modifying core configuration files
- Creating new package management files
- Adding unfamiliar dependencies
When you see these signs:
Prompt: "Please pause and explain the changes you're planning to make. Let's break this down into smaller, manageable steps that we can review and commit separately."
3. Advanced Topics¶
Advanced Git Commands for Cursor Workflows¶
Here are some Git commands you'll want Cursor to use:
# View branch history with graph
git log --oneline --graph --all
# Create and switch to a feature branch
git checkout -b feature/new-component
# Stage specific changes interactively
git add -p
# Temporarily save changes without committing
git stash save "work in progress on login form"
# Apply saved changes later
git stash pop
Git vs. GH-GitHub CLI¶
- Git handles all your local version control tasks (branches, commits, merges, and history).
- GH (GitHub CLI) is a complementary tool that simplifies interactions directly with GitHub itself—creating pull requests, managing issues, and handling code reviews.
To set up GH:
Then create a pull request:
Output:
Teaching Cursor Git Best Practices¶
Create a .cursor/rules/git-workflow.mdc
file to guide Cursor's Git usage:
# Git Workflow Rules
1. Branch Management:
- Create feature branches from main/master
- Use conventional branch naming: feature/, bugfix/, hotfix/
- Delete branches after merging
2. Commit Guidelines:
- Write conventional commit messages (feat:, fix:, docs:, etc.)
- Make atomic commits (one logical change per commit)
- Include tests with feature commits
3. Code Review Preparation:
- Squash related commits if requested
- Write detailed PR descriptions
- Link related issues/tickets
4. Safety Measures:
- Stash changes before switching branches
- Create backup branches for experimental changes
- Never force push to main/master
Automate Best Practices with .cursor/rules
¶
You don't have to type these instructions repeatedly. Instead, you can create a Cursor Rule, a simple markdown files (.mdc
) stored in .cursor/rules
—to automate consistent workflows:
Example CursorRule (.cursor/rules/git.mdc
):
- For new features, automatically create a Git branch named after the feature (e.g., `feature/<feature-name>`).
- Commit incrementally, with clear, semantic commit messages describing the changes.
- Record progress and next steps clearly in a `TODO.md`.
- When you're done, push your branch to GitHub and create a pull request using `gh pr create --title "<pr-title>" --body "<pr-body>"`.
- Include that this PR was generated automatically by `This PR was generated automatically by [Cursor](https://www.cursor.com/)`.
Cursor automatically reads and applies these rules when you're working, creating consistent workflows effortlessly.
What's Next? (Foreshadowing Part 2)¶
In Part 2, we'll dive deeper into advanced techniques, like using stacked PRs, analyzing your project's history with git log
, and quickly debugging with git bisect
. These methods combine Git and Cursor into a powerful, anxiety-free coding workflow.
Remember: Git is your safety net, but it works best when you use it proactively. Don't wait until after Cursor has made extensive changes to start thinking about version control.