Git
AI projects change constantly — new prompts, models, pipelines. Git keeps you organized, enables team collaboration, and lets you roll back mistakes.
Git is a time machine for code — save snapshots, branch into parallel timelines, and merge the best timeline back to main.
Visual Workflows
Start here — study each diagram, then use + / − to zoom if needed.
Overview
Scroll inside the frame · use + / − to zoom
Scroll inside the frame · use + / − to zoom
Branching and Feature Development
Scroll inside the frame · use + / − to zoom
How feature branches stay isolated from main until ready to merge.
Pull Request and Merge Strategies
Scroll inside the frame · use + / − to zoom
From PR to merged code — including conflict resolution.
Release Workflow
Scroll inside the frame · use + / − to zoom
How tested code moves from development to live users.
Open Source — Fork and Clone
Scroll inside the frame · use + / − to zoom
Contributing to or copying someone else's repository.
Key Takeaways
- 1.Git tracks code from your laptop to GitHub — branches, PRs, merges, and releases.
- 2.Flow: Working Directory → git add → Staging → git commit → Local Repo → git push → GitHub.
- 3.Feature branches isolate work. git pull = fetch + merge.
Real Example
Scenario
You want to test a new RAG chunking strategy without breaking the working version.
What you would do
Create branch experiment/chunking, test it, compare results, then merge the winner into main via pull request.
Practice Task
Run git init in an empty folder. Create README.md, commit it, create branch feature/test, make a second commit, switch back to main, and merge the branch. Run git log --oneline to see your history.
Commands
Commands to Remember
git init # initialize Git in a new projectgit clone <url> # copy a remote repository locallygit status # show current repository stategit checkout -b <branch> # create and switch to a new branchgit add . # stage all modified filesgit commit -m "message" # save staged changes as a commitgit push origin <branch> # upload local branch to GitHubgit fetch # download remote changes without merginggit pull # fetch and merge latest remote changesgit merge <branch> # merge another branch into currentgit rebase <branch> # replay commits on top of another branchgit cherry-pick <commit> # copy a specific commitgit log --oneline # view concise commit historygit stash # temporarily save uncommitted changesgit stash pop # restore latest stashed changes
Cheat Sheet
Quick recap
quick ref- •HEAD → current branch → latest commit
- •Flow: Working Dir → git add → Staging → git commit → Local Repo
- •git push uploads · git fetch downloads · git pull = fetch + merge
- •Feature branches isolate work · PR before merging to main
- •Merge strategies: merge commit · squash · rebase
- •Cherry-pick copies a specific commit to another branch
- •Fork = your copy of someone's repo · Clone = download locally
- •Release: dev → QA → internal beta → production tag v2.0
Common Mistakes
- ✕Committing API keys or .env files
- ✕Working directly on main branch
- ✕Not pulling before pushing
- ✕Ignoring merge conflicts instead of resolving them