More in Git
Undo the last commit but keep the changes
Git
Moves HEAD back one commit and leaves everything staged, which is what you usually want after committing too early.
Show what a merge will do before doing it
Git
Lists the commits and the files a merge would bring in, so a surprise is less likely.
Recover a branch you deleted
Git
The reflog remembers where HEAD has been for about ninety days, so a deleted branch is almost never really gone.
List branches merged into main
Git
Finds the branches that are safe to delete, and the ones that are not.
Find the commit that introduced a bug
Git
Binary search across history. Mark a known good and a known bad commit and git narrows it down for you.
Stop tracking a file without deleting it
Git
For the config file that should never have been committed. Add it to .gitignore afterwards.
Amend a commit without changing its message
Git
Adds forgotten files to the previous commit and leaves the message exactly as it was.
Random picks
Find the largest files with PowerShell
Shell
The Windows counterpart to du | sort | head.
Follow redirects and show only the headers
Networking
Traces a redirect chain to its destination without downloading the body.
Format a number as currency
JavaScript
Intl handles the symbol, the separators and the decimal places for the locale, so you never hand-roll them.
Type a fetch response safely
TypeScript
unknown forces a parse step rather than letting an any spread silently through the codebase.
Safe navigation and fetch in Ruby
Ruby
&. stops at nil; fetch raises rather than returning nil when a key is genuinely required.
Extract matches with a regular expression
Text Processing
grep -o prints only the matching part, which turns grep into a crude extractor.
Centre a box, two ways
Web & CSS
Grid is one line. Flex is three and gives you control over the axes separately.
A regular expression for ISO 8601 dates
Text Processing
Matches a date, optionally with a time and a zone. Deliberately strict about separators.