AI Hints
Home›Git & GitHub Tutorial›Cheat Sheet and Next Steps
Git & GitHub · Lesson 142 of 144

The Git Cheat Sheet

Everyday commands.

⏱ 2 min read▶ Video at 2:38:39🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

Here are the commands you learned, collected in one place. Pause on these screens, or take a screenshot, and keep them nearby while you practise.

The Git Cheat Sheet
From the video: The Git Cheat Sheet
  • Every command, in one place
  • Pause or screenshot
  • Keep it nearby

Every day

These are the everyday commands. Status, to see what's going on. Add, to stage. Commit, to save a snapshot. Log, to read history. And diff, to see exact changes.

CommandWhat it does
git statuswhat's going on
git add <file> / .stage changes
git commit -m "msg"save a snapshot
git log --oneline --graphread history
git diff / --stagedsee exact changes

Branches and GitHub

Next, branches and GitHub. Switch dash c creates a branch. Merge brings one into another. Clone, pull and push talk to GitHub. And remote add connects a repository to it.

CommandWhat it does
git switch -c <name>create and switch
git merge <branch>combine branches
git clone <url>copy a repository
git pull / git pushdownload / upload
git remote add origin <url>connect to GitHub

Undo and rescue

And the undo commands. Restore discards edits, or unstages with dash dash staged. Amend fixes the last commit. Revert undoes a shared commit. Reset moves back local commits. Stash shelves work. And reflog rescues almost anything.

CommandWhat it does
git restore [--staged] <file>discard or unstage
git commit --amendfix the last commit
git revert <hash>undo, safely
git reset [--soft|--hard]move back, local only
git stash / git reflogshelve / rescue

Summary

Status, add, commit, branch, merge, push, pull, and the undo commands. That's Git. Next, where to go from here.

Key takeaways
  • Everyday: status, add, commit
  • Teamwork: branch, PR, pull, push
  • Rescue: restore, revert, reflog
Next up: What to Learn Next — your Git roadmap