Part 5 of 5 · Beginner's Handbook
Tips & Tricks
You've got the fundamentals. This part is a grab bag of things that save real time once the basics are automatic — shortcuts, cleanup tools, and a peek at automation.
New here? This part assumes you're comfortable with the everyday commit/push cycle from Part 1. Each trick below is independent, so feel free to skip around.
01 Git Aliases — Shorten Your Commands
Tired of typing git status fifty times a day? Give it a shortcut:
Now git st, git co main, and git cm "message" all
work exactly like the full commands.
02 Useful Global Settings
All of these live in a plain text file at ~/.gitconfig you can also just open
and edit directly.
03 Stashing — Shelve Work Without Committing
Say you're mid-change and suddenly need to switch branches to fix something urgent, but
you're not ready to commit. git stash tucks your uncommitted changes away so
your working directory is clean again:
git stash pop re-applies your changes and removes them from the stash list.
Use git stash apply instead if you want to re-apply without removing it, in
case you need the same stash on another branch too.
04 Interactive Rebase — Clean Up History Before Pushing
Made three messy "wip" commits in a row and want to squash them into one clean commit before opening a PR? Interactive rebase lets you rewrite recent, not-yet-pushed history:
This opens a list of your last three commits in your editor, each prefixed with
pick. Change the word next to any commit you want to fold into the one above to
squash (or the shorthand s), save, and Git combines them and lets
you write a single clean commit message — the same idea as squash-merging a pull request
(see Part 3), just done locally before you even push.
Golden rule: only rebase commits you haven't pushed yet, or that you're certain no one else has pulled. Rebasing shared history rewrites it, which causes real headaches for anyone who already has the old version.
05 Cherry-Picking a Single Commit
Need just one specific commit from another branch, without merging everything else from it? Grab its commit hash and cherry-pick it onto your current branch:
Common use case: a hotfix was committed on a feature branch by mistake, and you need it on
main right now without waiting for the whole feature to be ready.
06 Log & Blame Tricks
07 GitHub Search & Keyboard Shortcuts
A few things that speed up browsing GitHub itself, not the terminal:
- Press
ton any repo page to fuzzy-search and jump straight to a file by name. - Press
.(period) on any repo page to open it in a full web-based VS Code editor, right in the browser. - Press
/anywhere on GitHub to jump to the search bar. - In search,
filename:package.json org:your-orgstyle qualifiers narrow results — GitHub's search supports dozens of these (is:pr,is:open,author:username,language:python, and more).
08 A Taste of GitHub Actions
GitHub Actions runs automated steps every time something happens in your repo — most commonly, running tests automatically on every push or pull request (these are the "status checks" mentioned in Part 3). It's a big topic on its own, but the entry point is small: a YAML file — a plain-text format that uses indentation to show structure, similar to how Python uses indentation instead of curly braces — placed in a specific folder.
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm install
- run: npm test
This particular example assumes a Node.js project — swap npm install and
npm test for whatever commands actually install and test your own project.
Commit the file and push it — GitHub picks it up automatically and runs it on every future
push, showing a green check or red cross right on your commits and pull requests. Combined
with the branch protection rule from Part 3 that
requires status checks to pass, this is how teams stop broken code from being merged. You
can also check on a run without leaving the terminal using the GitHub CLI from
Part 2 — see the cheat sheet below.
09 Tips & Tricks Cheat Sheet
| git stash / git stash pop | Shelve uncommitted changes, then bring them back later |
| git rebase -i HEAD~n | Interactively edit, squash, or reorder your last n commits |
| git cherry-pick <hash> | Apply one specific commit from another branch onto the current one |
| git log --oneline --graph --all | Visualize branch and merge history in the terminal |
| git blame <file> | See who last changed each line, and in which commit |
| git config --global alias.<name> "<command>" | Create a shortcut for any Git command |
| gh run list | See recent GitHub Actions runs for the current repo, from the terminal |
That's the whole handbook. Head back to the home page any time you need to jump to a different chapter.