Git and GitHub for Vibe Coders
I've been coding with AI tools like Cursor, Claude Code, and OpenAI Codex for a while now, and let me tell you – it's both amazing and terrifying. One moment you're asking AI to "add user authentication to this app," and the next moment you're staring at 200 lines of generated code wondering if it just broke your entire project.
And this is called vibe coding (coined by Andrej Karpathy) – using AI to generate code based on prompts and vibes rather than writing every line yourself. It's incredibly powerful, but it can also turn your codebase into chaos if you're not careful.
That's where Git and GitHub come in. Think of them as your safety net when AI coding goes sideways.
Why vibe coders desperately need Git
Here's the thing about vibe coding: you often don't fully understand what the AI just generated. Sure, it looks right, and it might even work, but what happens when you realize it broke something else? Or when you want to undo that "small refactor" that turned into a complete rewrite?
Without Git, you're basically coding without a parachute.
Git is essentially a time machine for your code. Every commit is a snapshot you can return to, and every branch is a parallel universe where you can experiment without consequences.
Git vs GitHub
I used to think Git and GitHub were the same thing. Spoiler alert: they're not.
- Git is the actual version control system that runs on your computer. It works completely offline and tracks all your changes locally. You can use Git without ever touching the internet.
- GitHub is a website that hosts your Git repositories online. It's like Google Drive for your code repositories, but with extra features like Issues, Pull Requests, and Actions.
Think of it this way: Git is like having a really good filing system for your documents, and GitHub is like having that filing system backed up to the cloud where others can collaborate with you.
Installing Git (first things first)
Before we can configure Git, we need to make sure it's actually installed on your system. Let's check if you already have it:
git --version
If you see something like git version 2.39.0
, you're good to go! If you get a "command not found" error, you need to install Git.
On macOS
The easiest way is using Homebrew (if you have it):
brew install git
Or download the installer from git-scm.com. macOS also comes with an older version of Git that gets installed when you run git
for the first time, but I recommend getting the latest version.
On Windows
Download the installer from git-scm.com. It comes with Git Bash, which gives you a Unix-like terminal that's perfect for running Git commands.
On Linux
Most Linux distributions include Git in their package managers:
Ubuntu/Debian:
sudo apt update
sudo apt install git
CentOS/RHEL/Fedora:
sudo yum install git
# or on newer versions:
sudo dnf install git
Once installed, run git --version
again to confirm it's working.
Setting up Git (the boring but necessary part)
Before you start, you need to tell Git who you are. Run these commands once:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
That's it. Now Git will stamp your name on every commit you make. You only need to do this once per computer.
The basic Git workflow that changed my coding life
Here's the workflow I use every single day:
1. Check what's changed
git status
This shows you which files have been modified, added, or deleted. I probably run this command 50 times a day. It's like asking Git "what's different since my last commit?"
2. Stage your changes
git add .
This tells Git "I want to include all these changes in my next commit." You can also add specific files with git add filename.js
if you want to be more selective.
3. Commit your changes
git commit -m "Add user authentication system"
This creates a permanent snapshot of your staged changes. Write a clear message describing what you did. Future you will thank you for this.
4. Push to GitHub
Before you can push, you need to connect your local repository to a GitHub repository. Here's how:
First time setup:
- Create a new repository on GitHub (go to github.com, click the "+" icon, select "New repository")
- Copy the repository URL (it looks like
https://github.com/yourusername/your-repo-name.git
) - Connect your local repo to GitHub:
git remote add origin https://github.com/yourusername/your-repo-name.git
git branch -M main
git push -u origin main
After the first setup:
git push
The first command (git remote add origin
) tells Git where your GitHub repository is located. The second command (git branch -M main
) ensures your main branch is named "main" (GitHub's default). The third command (git push -u origin main
) pushes your code and sets up tracking so future pushes just need git push
.
This uploads your commits to GitHub, backing up your work and making it available to collaborators.
I do this cycle constantly – sometimes every 10-15 minutes when I'm actively coding with AI assistance. Each commit is a checkpoint I can return to if things go wrong.
Creating a repository (your project's home)
To start tracking a new project:
git init
This creates a hidden .git
folder in your current directory and starts tracking changes.
If you want to work on an existing project from GitHub:
git clone https://github.com/username/repository-name.git
This downloads the entire project and its history to your computer. For example, look how I am cloning a GitHub repo called optisharp to my computer.
Branches: Your experimentation playground
Branches are where Git really shines for vibe coders. Think of them as parallel timelines where you can try things without affecting your main code.
Create a new branch:
git checkout -b experiment/new-feature
Now you can ask AI to implement that crazy idea you had. If it works great, you can merge it back. If it breaks everything, just switch back to your main branch:
git checkout main
And delete the failed experiment:
git branch -d experiment/new-feature
I use branches for literally everything:
fix/header-bug
for bug fixesfeature/payment-integration
for new featuresexperiment/ai-suggestions
for testing AI-generated code
The .gitignore file (don't commit everything)
Some files shouldn't be tracked by Git. Create a .gitignore
file in your project root:
node_modules/
.env
*.log
dist/
.DS_Store
This tells Git to ignore:
node_modules/
(huge folder of dependencies).env
(contains secret keys)*.log
(log files)dist/
(build output).DS_Store
(macOS system files)
Never commit secrets, large binary files, or generated content. Your repository should only contain source code and configuration files.
My vibe coding safety rules
After months of AI-assisted coding, here are the habits that have saved me countless times:
Commit before asking AI to change anything major
Before telling Claude "refactor this entire component," commit your current working state. This gives you an instant undo button.
Use descriptive commit messages
Instead of "updates" or "fixes," write:
- "Add user registration form with validation"
- "Fix mobile navigation menu bug"
- "Refactor database connection logic"
Review AI changes before committing
Use git diff
to see exactly what changed:
git diff
This shows you line-by-line what the AI added, removed, or modified. Sometimes AI changes more than you expected.
Push frequently
Don't let a day go by without pushing to GitHub. Your laptop could die, you could spill coffee on it, or you might accidentally run rm -rf
in the wrong directory (yes, I've done this).
GitHub: Your cloud backup and collaboration hub
GitHub adds powerful features on top of Git:
Issues: Track bugs and feature requests
Pull Requests: Review code changes before merging
Actions: Automate testing and deployment
Releases: Tag stable versions of your code
Even as a solo vibe coder, I use GitHub Issues to track what I want to build next. It's like having a todo list that's tied to your codebase.
When things go wrong (and they will)
Undoing your last commit
git reset --soft HEAD~1
This undoes your last commit but keeps the changes in your working directory. Useful when you commit too early or have a typo in your commit message.
Going back to a previous commit
git log --oneline
This shows your commit history. Find the commit you want to return to and:
git checkout abc1234
(Replace abc1234
with the actual commit hash)
Dealing with merge conflicts
Sometimes Git can't automatically merge changes. When this happens, Git will mark the conflicting sections in your files:
<<<<<<< HEAD
Your current code
=======
The conflicting code
>>>>>>> branch-name
Edit the file to keep what you want, remove the conflict markers, then commit the resolved version.
My current vibe coding setup
Here's how I actually use Git and GitHub in my day-to-day AI-assisted coding:
- Start with a branch for each new feature or experiment
- Commit every 15-20 minutes when actively coding
- Push at least once per coding session for backup
- Use clear commit messages that explain the "why," not just the "what"
- Review AI changes with
git diff
before committing - Create Pull Requests even for solo projects to review my own work
This might seem like overkill, but it's saved me so many times when AI-generated code broke something unexpectedly.
The honest truth about learning Git
Git has a learning curve. Commands like rebase
, cherry-pick
, and bisect
can seem intimidating at first. But here's the thing: you don't need to master everything on day one.
Start with the basics I've covered here:
git add
git commit
git push
git status
git checkout
(for branches)
These five commands will handle 90% of your needs as a vibe coder. You can learn the advanced stuff when you actually need it.
The key is to start using Git now, even if you don't understand everything. It's better to have imperfect version control than no version control at all.
Why this matters for vibe coders specifically
Traditional programmers write code line by line, understanding every character. They might go hours between commits because they're building something incrementally.
Vibe coders work differently. We prompt AI, get large chunks of generated code, test it, and iterate. This creates unique challenges:
- Large, sudden changes that might break existing functionality
- Code we don't fully understand initially
- Rapid experimentation with different approaches
- Need to roll back entire features quickly
Git is perfectly suited for this workflow. Every commit is a checkpoint, every branch is an experiment, and every push is a backup of your progress.
Getting started today
If you're not using Git yet, here's what to do right now:
- Install Git from git-scm.com
- Create a GitHub account at github.com
- Run the config commands to set your name and email
- Go to your current project and run
git init
- Create a
.gitignore
file for your project type - Add and commit your existing code
- Create a repository on GitHub and push your code
Don't wait until you "understand Git better." Start with the basics and learn as you go.
Final thoughts
Git and GitHub aren't just tools for professional developers – they're essential safety equipment for anyone doing vibe coding. The ability to experiment fearlessly, knowing you can always undo changes, is liberating.
I've seen too many people lose hours of work because they didn't have version control. Don't be one of them. Start using Git today, commit frequently, and let AI help you build amazing things without the fear of breaking everything.
Your future self will thank you when you can confidently tell Claude Code or Cursor to "refactor this entire codebase" knowing you can always go back to the last working version.
Happy vibe coding!
- ← Previous
How to Run Omarchy on a MacBook via UTM
Comment via email