跳至主要内容

Git

Track every change, never lose work.

Git is a version control system. It records every change you make to your files, so you can always go back to previous versions.


Why Git Matters for AI Workflows

When AI edits your files directly, you need a safety net:

Without GitWith Git
AI makes a mistake → you lose workAI makes a mistake → you revert
"What did AI change?" → you guess"What did AI change?" → you see exactly
Undo is one step backUndo is unlimited

Git isn't just for programmers anymore. It's essential for anyone letting AI modify their files.


Core Concepts

Repository

A folder tracked by Git. All changes inside this folder are recorded.

Commit

A snapshot of your files at a point in time. Like a save point in a video game.

Diff

The difference between two versions. Shows exactly what changed.


Getting Started

Install Git

Mac:

# Usually pre-installed. Check with:
git --version

# If not installed:
brew install git

Windows: Download from git-scm.com

Linux:

sudo apt install git  # Ubuntu/Debian
sudo dnf install git # Fedora

Configure Git

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Essential Commands

Start tracking a folder

cd my-project
git init

See what changed

git status

Save your changes

git add .
git commit -m "Describe what changed"

View history

git log --oneline

See what AI changed

git diff

Undo AI's changes (before committing)

git checkout -- filename

Go back to a previous version

git revert HEAD

A Typical Workflow

  1. Before AI edits: Make sure your work is committed
  2. AI makes changes: Review the diff
  3. If good: Commit with a descriptive message
  4. If bad: Revert the changes
# 1. Start clean
git status # should show "nothing to commit"

# 2. Let AI work...
# (AI edits your files)

# 3. See what changed
git diff

# 4a. If you like the changes:
git add .
git commit -m "AI: Fixed grammar in chapter-3.md"

# 4b. If you don't like the changes:
git checkout -- .

Visual Tools

The command line works, but visual tools make Git easier:

ToolPlatformNotes
VS CodeAllBuilt-in Git panel
GitHub DesktopMac/WinBeginner-friendly
GitKrakenAllVisual branches
SourcetreeMac/WinFeature-rich

Going Deeper


Git will be covered hands-on in the Track Changes task.