AI Dev Guide
Git Beginner

Git Basics for AI Development

Essential Git concepts and how to use version control effectively when working with AI coding tools

What Is Git?

Git is a tool that records the history of changes to your files.

Think of it like save points in a video game. You save your progress at key moments, and if something goes wrong, you can always go back.

This is especially important in AI development. AI can modify lots of code at once, so always having a safe state to return to is your safety net.

5 Commands to Learn

1. git init — Start tracking

cd my-project
git init

Run this once at the start of a new project.

2. git status — Check what changed

git status

Shows which files have been modified. Make a habit of running this often.

3. git add — Stage files to save

# Stage a specific file
git add src/App.tsx

# Stage all changes
git add .

4. git commit — Save

git commit -m "Add login feature"

Write a short message after -m describing what you did.

5. git log — View history

git log --oneline

Shows a list of past save points.

Why Git Matters in AI Development

1. Undo AI’s Changes

When AI makes unwanted changes:

# Revert all changes back to the last commit
git checkout .

If you committed before the AI worked, you can always return to safety.

2. See What Changed

git diff

Review what AI actually modified. Always check the diff before accepting changes.

3. Let AI Write Commit Messages

Ask the AI: “Commit the current changes and write a commit message.” It’ll summarize what changed for you.

Git Workflow for AI Development

1. Commit before starting (create a safe save point)
       |
2. Ask AI to do the work
       |
3. git diff to review changes
       |
4. If OK: git add + git commit
   If not: git checkout . to revert

Repeat this cycle.

.gitignore — Files to Exclude

Create a .gitignore file to tell Git which files to ignore.

node_modules/
.env
dist/
.DS_Store

Most importantly, never commit .env files. They contain passwords and API keys.

GitHub — Store Code Online

Git works locally on your machine. GitHub adds:

  • Backup if your computer dies
  • Code sharing with others
  • Auto-deploy integration with Vercel and similar services
# Create a GitHub repo and push
gh repo create my-project --public --source=. --remote=origin --push

Common Mistakes

Accidentally committed .env

Your API keys may be exposed. Rotate (re-issue) them immediately.

Committed node_modules/

Your repository becomes huge. Add it to .gitignore, then:

git rm -r --cached node_modules/
git commit -m "Remove node_modules from tracking"

AI suggested git push --force

Don’t do it unless you understand exactly why. It destroys history. If AI suggests this, ask “Why is force push necessary?” before proceeding.

Next Steps