Reference mirrors GIT_AND_GITHUB_GUIDE.md; the lab is a simplified single-file simulator.
What Git and GitHub are
- Git tracks versions of your project on your machine.
- GitHub hosts Git repositories online for collaboration.
Prerequisites & identity Expand
Install Git from git-scm.com/downloads. Create a GitHub account at github.com.
git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
Authentication (PAT, SSH, CLI, credential manager)
GitHub does not accept account passwords for Git over HTTPS. Use a Personal Access Token, SSH keys, GitHub CLI (gh auth login), or the OS Git Credential Manager.
See the full guide for token scopes, ssh-keygen -t ed25519, and testing with ssh -T git@github.com.
Happy path (clone, daily cycle)
git init git remote add origin https://github.com/USER/REPO.git # OR git clone https://github.com/USER/REPO.git
git add . git commit -m "Your message" git push origin main git pull
Branching & merge
git checkout -b feature-login # ... commits ... git checkout main git pull origin main git merge feature-login git push origin main
Merge vs rebase
Merge preserves full history; adds a merge commit.
Rebase replays your commits on top of main for a linear history — avoid on shared branches you do not own.
git checkout feature-branch git pull origin main --rebase
Fetch vs pull & safe update
git pull fetches and merges. git fetch only downloads — inspect before merging.
git fetch origin git log main..origin/main git merge origin/main
Quick check (interactive)
Flip each card — term on the front, answer on the back.
Cheat sheet
| Command | Description |
|---|---|
| git status | Check file status |
| git log --oneline --graph | Visual commit history |
| git diff | Unstaged changes |
| git branch -a | List local and remote branches |
| git remote -v | Show remote URLs |
| git commit --amend | Fix the last commit message |
| git pull --rebase | Pull with rebase |
Command Center
1. Standard Workflow
2. Shelf Work (Stash)
3. Undo Mistakes
4. Branching
Working tree clean. Edit a file to start.
Next: Use (edit files) to create a change.
Dir
Index
Repo
Repo