The Ultimate Git & GitHub Cheat Sheet (2025 Edition)

🧠 The Ultimate Git & GitHub Cheat Sheet (2025 Edition)

Everything You Need to Master Version Control in One Place

If you’re a developer, DevOps engineer, data scientist, or just someone managing code β€” Git and GitHub are tools you must know.

This cheat sheet is your one-stop guide to commands, workflows, concepts, and best practices β€” perfect for beginners or anyone who wants to refresh and level up.

Git & GitHub Cheat Sheet PDF


πŸ“Œ What Are Git and GitHub?

TermPurpose
GitA distributed version control system that tracks code changes, supports collaboration, and manages history.
GitHubA cloud-based platform to host Git repositories with added features like issue tracking, pull requests, and CI/CD via GitHub Actions.

βš™οΈ Setting Up Git

βœ… Install Git

βœ… Configure Git

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Check configuration:

git config --list

πŸ” Git Workflow Summary

1. git add       β†’ Stage changes
2. git commit    β†’ Commit snapshot
3. git push      β†’ Upload to GitHub
4. git pull      β†’ Sync with remote

🧱 Essential Git Commands

CommandDescription
git initCreate a new Git repo
git clone URLCopy repo from GitHub
git statusSee current changes
git add .Stage all files
git commit -m "msg"Save changes
git push origin mainUpload to GitHub
git pullDownload + merge
git logView commit history
git diffShow file differences
git resetUndo commits
git rmDelete a file from Git

🌿 Working with Branches

CommandAction
git branchList branches
git checkout -b new-featureCreate and switch to a branch
git checkout mainSwitch to main
git merge featureMerge a branch
git branch -d branchDelete a branch

🌐 GitHub Collaboration Essentials

βœ… Create a Repository

  1. Go to https://github.com
  2. Click New
  3. Choose project name and visibility

βœ… Connect Local Repo to GitHub

git remote add origin https://github.com/yourname/repo.git
git push -u origin main

βœ… Fork + Pull Request Workflow

  1. Fork a repo
  2. Clone your fork
  3. Create a branch β†’ Commit β†’ Push
  4. Open a pull request (PR)

πŸ”’ .gitignore & README

  • .gitignore – Exclude files like: node_modules/ .env *.log
  • README.md – Always document your repo purpose, usage, and license

🚨 Undoing Changes (Safety Tools)

CommandUsage
git checkout -- fileDiscard unstaged changes
git reset HEAD fileUnstage file
git revert <commit>Revert a commit with history
git reset --hard HEAD~1Danger! Reset to 1 commit ago
git stashSave current uncommitted changes

πŸ› οΈ Advanced Git Features

FeatureCommand
Tagging versionsgit tag v1.0.0
Cherry-pick commitgit cherry-pick <commit-id>
Rebase branchgit rebase main
Stash applygit stash apply
Remove remotegit remote remove origin

🧩 Key Git Concepts

ConceptExplanation
Staging AreaTemporary space to prepare commits
HEADCurrent branch reference
Fast-ForwardGit just moves pointer if no divergence
Detached HEADNot on any branch – be cautious
OriginDefault name for remote GitHub repo

πŸš€ GitHub Features You Should Know

FeatureUse
ActionsCI/CD pipelines
IssuesBug & feature tracking
ProjectsKanban/task boards
DiscussionsCommunity Q&A
WikisCollaborative documentation
PagesHost static sites

πŸ“˜ Best Practices

  • βœ… Commit small, meaningful changes
  • βœ… Pull before pushing
  • βœ… Always work in a feature branch
  • βœ… Use .gitignore and README.md
  • βœ… Write clear commit messages
  • βœ… Enable 2FA on GitHub

🧠 Common Git Errors and Fixes

ErrorFix
fatal: not a git repoRun in repo or git init
Merge conflictManually edit, then git add + git commit
Permission denied (publickey)Add your SSH key to GitHub
non-fast-forwardDo git pull --rebase before pushing

πŸ§ͺ GitHub Tips for Teams

  • Use Protected Branches
  • Require Pull Requests before merge
  • Use CODEOWNERS to assign reviewers
  • Use Actions for automatic testing/deployments
  • Add badges in README (build passing, license, etc.)

πŸ“š Cheat Sheet Resources

ResourceLink
Git CLI Cheat Sheet (PDF)https://education.github.com/git-cheat-sheet-education.pdf
GitHub Docshttps://docs.github.com
Git SCM Docshttps://git-scm.com/doc
GitHub Learning Labhttps://lab.github.com
DevOpsSchool Git Bloghttps://www.devopsschool.com/blog/category/git

🏁 Final Words

Whether you’re writing solo projects or managing an enterprise CI/CD pipeline, Git + GitHub are tools you’ll use every day.

Master the basics. Learn to collaborate. Push fearlessly. Revert confidently.
That’s the power of version control.


Related Posts

General Build Pipeline (CI) in Azure DevOps

Let’s walk through a general-purpose Azure DevOps build pipeline template that can be applied to most common application types (web apps, APIs, microservices, etc.) using CI/CD best…

Read More

Kubernetes Certifications in 2025: Which One Should You Choose?

Kubernetes Certifications in 2025: Which One Should You Choose? Kubernetes has become the cornerstone of modern cloud-native application deployment and orchestration. Whether you’re a beginner just diving…

Read More

Top 5 Kubernetes Tools That Will Replace Your Bash Scripts in 2025

πŸš€ Top 5 Kubernetes Tools That Will Replace Your Bash Scripts in 2025 For years, DevOps engineers and platform teams have relied on Bash scripts to automate…

Read More

Kubernetes Horror Stories (and What We Learned From Them)

☠️ Kubernetes Horror Stories (and What We Learned From Them) Because what doesn’t kill your cluster makes it stronger. Kubernetes is powerful β€” but with great power…

Read More

Why Your Kubernetes Costs Are Out of Control – and How to Fix It (2025 Guide)

πŸ’Έ Why Your Kubernetes Costs Are Out of Control – and How to Fix It (2025 Guide) Kubernetes is powerful β€” but it isn’t cheap. While it…

Read More

Production-Ready Kubernetes YAML Templates (Ingress, PV, CronJobs) β€” From Basics to Advanced

☸️ Production-Ready Kubernetes YAML Templates (Ingress, PV, CronJobs) β€” From Basics to Advanced Kubernetes is powerful. But without properly crafted YAML manifests, your deployments can be unstable,…

Read More
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x