Introduction
Hey everyone, I'm Oil. This is a zero-to-one guide to Git and GitHub—covering core concepts and common commands, what problems they actually solve, and how to drive them in plain language through your AI Agent.
Almost every Vibe Coding beginner hits the same disaster: your site runs cleanly for a few rounds, then you ask AI for one new feature or style tweak, it edits a dozen files, and the page white-screens. Asking AI to undo the damage only tangles it further until you start over—or you resort to copying site-v1, site-final, and site-final-REAL folders all over your Desktop.
That happens because your project has no version control. Every software team and AI Agent relies on the same standard pair of tools: Git and GitHub. You no longer have to memorize dozens of cryptic terminal flags—once you understand the mental model, plain-language prompts let your AI handle checkpoints, rollbacks, branches, and cloud sync directly.
Local Checkpoints & Version Rollback
First, let's master version control locally on your own computer: saving checkpoints and rolling back cleanly whenever AI breaks something.
1. Git vs. GitHub
Beginners often lump Git and GitHub together. One is a local program on your computer; the other is a cloud website:
Git: Your Local "Single-Player Savegame Manager"
Git is a command-line version-control program running locally on your computer.
Each time AI finishes a clean milestone in your project folder, Git records a snapshot (V1, V2, and so on). If a later prompt ruins the layout or crashes the app, you reload V1 in seconds—just like saving before a boss fight in a single-player game. Forget to save, and a wipe means starting from scratch.
GitHub: Cloud Saves & Multiplayer Lobby
Git alone stays on your local drive. If you switch laptops or want someone else to contribute, they can't reach your files.
GitHub is a cloud code-hosting platform where you sync local Git repositories online—just like cloud saves letting you pick up your game on a friend's computer.
Note that Git and GitHub are not locked together. Other hosting platforms like GitLab or Gitee work with Git too (in theory you could even copy a .git folder onto a USB stick), though GitHub is by far the global standard.
2. Init, Commit, and Roll Back
To start using Git, just open your AI Agent (Codex, Claude Code, Cursor, etc.) and steer it in plain English:
Step 1: Install Git and Initialize Your Project (Init)
If Git isn't installed yet, tell any AI Agent:
Git does not track every folder on your machine automatically—movie or photo folders don't need code history. Once you create a dedicated project folder (see Everyday AI Agent Workflows), tell your AI:
The AI runs git init, creating a hidden .git folder inside your project root that stores all version history and Git config. Never delete or manually edit .git.
Step 2: Saving a File ≠ Creating a Version — Commit Is the Checkpoint
A common misconception is that saving a file (or having AI write a file) automatically creates a Git version.
It doesn't. Editing and saving only changes your working directory. To actually save a checkpoint, you must make a Commit.
Whenever AI finishes a small feature and it looks good in your browser, save a checkpoint:
The AI runs a commit command (such as git commit -m "Finish homepage hero layout") with a clear summary of what changed. (On a brand-new machine, Git may ask for your name and email once to label your commits.)
Step 3: Checking Status, One-Step Rollback, and Earlier Versions
After a dozen prompts, if you forget what's changed or uncommitted, ask (corresponding to git status and git diff):
With regular commits, big experiments feel stress-free. If the AI breaks your layout after V1, don't force it to patch broken code—just roll back:
The AI clears the messy working-tree edits and restores your folder to the clean state from your last commit.
If you already committed V1, V2, and V3 before realizing V2 and V3 went down the wrong path, ask AI to list history (git log) and return to an earlier commit:
Beginner Tip: Pair with a Visual Git Client (Oil Git)
Operating Git purely through chat can feel abstract at first because you never see the timeline inside .git.
I strongly recommend installing my open-source desktop Git client Oil Git (repo: oil-oil/oil-git). Keep it open beside your AI Agent so you can watch every commit appear on the timeline, inspect exact line-by-line diffs, and even swipe before/after comparisons on updated images.
Branching & Resolving Merge Conflicts
A single timeline works for linear tweaks. Once you want to build two features at once—or test a risky experiment—you need Git Branches.
1. The Main Branch & Parallel Features
By default, a Git repo has one primary branch called main—think of it as a tree's sturdy main trunk, kept clean and working at all times.
To work on new features safely, sprout separate branches off main:
Why Develop on Separate Branches?
Suppose you're upgrading your personal site (from Vibe Coding a Personal Website from Scratch) with two new features at once:
- Feature A (
contactbranch): Adds a "Contact Me" section at the bottom plus a "Contact" link in the top-right navbar. - Feature B (
dark-modebranch): Adds dark mode styling plus a theme toggle button in the top-right navbar.
Editing both directly on main tangles them together—if dark mode turns messy and you want to scrap it, untangling it risks breaking your finished Contact feature.
With branches, both start cleanly from the same stable main. If one experiment flops, you simply delete that branch—main and the other feature remain completely untouched.
Creating and Switching Branches in Plain Language
Skip memorizing git checkout -b or git switch—just tell your AI:
To jump back to main:
Just remember to commit finished work on a branch before switching, and always branch your second feature off main so both grow cleanly from the same stable base.
2. Merging Code & Resolving Conflicts
Once a feature branch is tested and ready, fold it back into the trunk via a Merge. When two branches edit the exact same region of a file differently, Git raises a Merge Conflict:
Merging the First Branch Cleanly
First, fold contact into main:
Because main hasn't moved since you branched, this merges smoothly and advances main.
Why the Second Branch Triggers a Conflict
Now main has the Contact navbar link, so dark-mode is out of sync with main—and both branches modified the exact same top-right navbar code in different ways. Git can't safely guess which version to keep, so it pauses and flags a Conflict.
Letting Your AI Agent Merge & Resolve Conflicts
AI Agents excel at combining both sides cleanly. Switch to the unmerged branch, pull in the latest main to resolve conflicts there, then merge back into main:
Verify both buttons appear properly on screen, then finish:
Because the conflict is already resolved, main now cleanly includes both features.


