More in Git
Amend a commit without changing its message
Git
Adds forgotten files to the previous commit and leaves the message exactly as it was.
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.
Stop tracking a file without deleting it
Git
For the config file that should never have been committed. Add it to .gitignore afterwards.
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.
Search the whole history for a string
Git
Finds every commit whose diff added or removed a piece of text, including in files long since deleted.
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.
Random picks
Group rows into a JSON array
Databases
Returns one row per author with their posts nested, instead of a join that repeats the author on every row.
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.
Exhaustiveness check on a switch
TypeScript
Assigning to never makes the compiler fail the build when a new union member is added and left unhandled.
Find the largest files under a directory
Shell
Sorts everything beneath the working directory by real disk usage and shows the twenty worst offenders.
An RSS feed skeleton
Data Formats
The minimum a reader needs. Dates must be RFC 822, which is the part most generators get wrong.
Rename a batch of files with a pattern
Shell
Strips a prefix from every file in a directory using shell parameter expansion, no rename utility required.
Records and pattern matching in Java
Systems
A record plus a switch pattern removes most of the ceremony this used to take.
Type a fetch response safely
TypeScript
unknown forces a parse step rather than letting an any spread silently through the codebase.