Skip to content

Cheat Sheet

These are the commands you’ll use most often. It’s recommended to keep this open in a tab while you work, especially when starting.

CommandWhat it does
git statusSee what files have changed since your last commit
git log --onelineSee a short history of recent commits
git diffSee exactly what lines changed in your files
git branchSee what branch you’re on
CommandWhat it does
git checkout mainSwitch to the main branch
git pullDownload the latest changes from GitHub
git checkout -b nameCreate a new branch and switch to it
git checkout nameSwitch to an existing branch
CommandWhat it does
git add .Stage all changed files for a commit
git add filenameStage a specific file only
git commit -m "msg"Commit your changes with a description
git push origin nameUpload your branch to GitHub
CommandWhat it does
git reset --soft HEAD~1Undo last commit, keep changes
git restore filenameDiscard changes to a specific file
git stashTemporarily shelve all changes
git stash popRestore your shelved changes
Terminal window
# Start fresh
git checkout main
git pull
# Create your branch
git checkout -b your-name/what-youre-doing
# ... do your work ...
# Save and upload
git add .
git commit -m "Describe what you did"
git push origin your-name/what-youre-doing
# Then open a Pull Request on github.com