0
Programming Foundations
Phase 0Module 3 of 14

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

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

Branching and Feature Development

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

How feature branches stay isolated from main until ready to merge.

Pull Request and Merge Strategies

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

From PR to merged code — including conflict resolution.

Release Workflow

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

How tested code moves from development to live users.

Open Source — Fork and Clone

100%
Loading diagram...

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 project
  • git clone <url> # copy a remote repository locally
  • git status # show current repository state
  • git checkout -b <branch> # create and switch to a new branch
  • git add . # stage all modified files
  • git commit -m "message" # save staged changes as a commit
  • git push origin <branch> # upload local branch to GitHub
  • git fetch # download remote changes without merging
  • git pull # fetch and merge latest remote changes
  • git merge <branch> # merge another branch into current
  • git rebase <branch> # replay commits on top of another branch
  • git cherry-pick <commit> # copy a specific commit
  • git log --oneline # view concise commit history
  • git stash # temporarily save uncommitted changes
  • git 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