Welcome to the Ultimate Git & GitHub Cheatsheet! This repository is a clean, structured, highly professional reference designed for daily development usage, interview revision, and quick mastering of version control.
Whether you are a terminal beginner committing your first lines of code or a senior engineer orchestrating complex interactive rebases, multi-branch workflows, and CI/CD pipelines, this guide covers everything with zero fluff and maximum practicality.
The cheatsheet is divided into 30 structured, self-contained chapters covering the entire spectrum of version control.
| Chapter | Topic | Key Commands |
|---|---|---|
| Chapter 01 | 🖥️ Terminal Basics | ls, cd, pwd, mkdir, rm |
| Chapter 02 | ⚙️ Initial Git Setup | git config, user.name, core.editor |
| Chapter 03 | 🏗️ Creating Repositories | git init, git clone, git status |
| Chapter 04 | 📥 The Staging Area | git add, git restore --staged, git add -p |
| Chapter 05 | ✍️ Committing Changes | git commit -m, git commit --amend, git diff |
| Chapter 06 | 🔍 Searching & Logs | git log, git grep, git blame, git reflog |
| Chapter 07 | 📦 Moving & Renaming | git mv, git mv -f, rename tracking |
| Chapter 08 | 🌿 Branching & Tagging | git switch, git switch -c, git tag |
| Chapter 09 | 🌐 Remotes & Publishing | git remote add, git push, git fetch |
| Chapter 10 | 🔀 Merge vs. Rebase | git merge, git rebase basics |
| Chapter | Topic | Key Commands |
|---|---|---|
| Chapter 11 | 🔄 Reset vs. Revert | git reset --hard, git revert, git clean |
| Chapter 12 | 🐙 GitHub Integration | git push -u origin, origin/main tracking |
| Chapter 13 | 📥 Fetching vs. Pulling | git pull --rebase, git fetch, force-with-lease |
| Chapter 14 | 🚫 Git Ignore Rules | .gitignore formatting, pattern matching |
| Chapter 15 | 🎒 Workspace Stashing | git stash, git stash pop, git stash -u |
| Chapter | Topic | Key Commands |
|---|---|---|
| Chapter 16 | 🔑 SSH Keys & Aliases | ssh-keygen, global .gitconfig alias scripts |
| Chapter 17 | 🍒 Cherry-Pick & Reflog | git cherry-pick, deep Reflog recovery, detached HEAD |
| Chapter 18 | 🔨 History Rewriting | git rebase -i, squash, fixup, reword, drop |
| Chapter 19 | 🏷️ Releases & SemVer | git tag -a, Semantic Versioning, pushing tags |
| Chapter 20 | 🤝 Forking & PR Workflows | upstream sync, pull requests, open-source setup |
| Chapter | Topic | Key Concepts |
|---|---|---|
| Chapter 21 | 💥 Conflict Resolution | Marker parsing, git mergetool, Meld/VS Code setup |
| Chapter 22 | 📐 Git Flow vs. Trunk | Git-Flow AVH, Trunk-Based Development, Monorepos |
| Chapter 23 | 🌳 Submodules & Worktrees | git submodule, git worktree add for multitasking |
| Chapter 24 | 🪝 Git Hooks & Husky | pre-commit, Husky, Commitlint integration |
| Chapter 25 | 🔬 Git Under the Hood | Blobs, Trees, Commits, Refs, plumbing cat-file |
| Chapter 26 | 💾 Large File Storage (LFS) | Git LFS config, .gitattributes line-endings |
| Chapter 27 | 🛡️ Security & Purging | GPG Signatures, git-filter-repo history purging |
| Chapter 28 | ⚙️ GitHub Actions CI/CD | YAML test configuration, skip ci, status pipelines |
| Chapter 29 | 📋 Conventional Commits | Standardize prefix structures, automated changelogs |
| Chapter 30 | 🗺️ Progressive Roadmap | Beginner-to-Expert roadmap, visual tooling list |
If you are in a rush, here are the most frequently used commands that every developer runs daily:
# 1. Start a new repository
git init
# 2. Check changes and status
git status
# 3. Diff staged changes
git diff --staged
# 4. Stage and commit changes (Conventional Commit style)
git add .
git commit -m "feat: implement payment validation"
# 5. Clean update from remote main using rebase (Linear history)
git pull --rebase origin main
# 6. Push features safely to origin branch
git push -u origin feature/loginTo get the most out of this cheatsheet, we suggest adopting this clean workflow for your daily project commits:
[ Code ] ➔ [ git status ] ➔ [ git diff ] ➔ [ git add -p ]
│
[ git push ] 🠔 [ git pull --rebase ] 🠔 [ git commit ]
- Audit modifications: Run
git statusandgit diffbefore doing anything. - Stage selectively: Use patch staging (
git add -p) to review your code blocks line-by-line while staging. - Draft commit: Write a structured commit using Conventional Commits style (
git commit -m "feat: ..."). - Pull safely: Pull remote updates using rebase (
git pull --rebase origin main). - Publish: Push features using
git push.
Enhance your GitHub browser experience with these highly recommended, developer-proven extensions:
- Octotree: Adds a full, interactive file tree sidebar on the left side of GitHub pages, allowing you to browse repositories without opening endless tabs.
- GitZip for GitHub: Enables double-clicking empty space next to folders/files to instantly download them individually as a
.zippackage. - Refined GitHub: Adds over 200 UX improvements to the default GitHub interface, including gray whitespace dots, clickable issue links, and visual feedback avatars.
This cheatsheet is a community-first developer resource. Contributions are highly welcome!
- Fork the repository and create your custom feature branch:
git switch -c feature/improved-git-hooks
- Make your edits following the standard Conventional Commits style.
- Keep descriptions highly technical, concise, and focused on real-world application.
- Open a Pull Request explaining what changes were introduced and why they improve the cheatsheet.
If you are looking to progressively master Git step-by-step, check out the comprehensive Progressive Git Mastery Roadmap containing visual interactive tools, the Pro Git Book guidelines, and VS Code productivity extensions.
Author: Tanmay Patil (GitHub: @tanmaypatil15)
Made with ❤️ for developers worldwide.