# === Initial Setup ===
# Run this once to start the project and link it to the cloud.
git init
# Create .gitignore FIRST (see .gitignore section)
git add .
git commit -m "Initial commit"
# Rename branch to 'main' (standard modern practice)
git branch -M main
# Link to your remote repository (Create empty repo on GitHub/GitLab first)
git remote add origin <repo-url>
# Push the first version and set the link
git push -u origin HEAD
# === Routine Feature / Bug Fix ===
# For 95% of your work (adding features, fixing bugs), stay on main.
# 1. Update local code (REQUIRED if working from multiple machines)
git pull
# 2. Paste AI code or make changes
# ... (AI generates code, you verify it works) ...
# 3. Save and Sync
git add .
git commit -m "Add dark theme to settings page"
git push
# === The "Risky Experiment" (Branching) ===
# Use this when asking the AI to do something destructive (e.g., "Refactor the entire database structure").
# 1. Create a sandbox branch
git switch -c experiment/database-refactor
# 2. Make changes
# ... (AI rewrites files) ...
# 3. Save to the sandbox
git add .
git commit -m "Attempt database refactor"
# 4. (Optional) Backup this experiment to cloud
git push
# === DECISION POINT ===
# Option A: It worked! Merge it.
git switch main
git merge experiment/database-refactor
git push # (Uploads current local branch to matching remote branch)
git branch -d experiment/database-refactor
# (Optional) If you pushed the branch earlier, delete it from remote:
git push origin --delete experiment/database-refactor
# Option B: It failed. Destroy it.
git switch -f main # Force switch, discarding uncommitted changes
git branch -D experiment/database-refactor # Warning: Permanently deletes unmerged branch with its commits
# (Optional) If you pushed this branch to remote earlier, clean it up:
git push origin --delete experiment/database-refactor