More in Git
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.
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.
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.
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.
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.
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
Add a column without locking the table
Databases
On Postgres 11 and later a nullable column with a default is a metadata-only change. Adding NOT NULL afterwards is the part that needs care.
Safe navigation and fetch in Ruby
Ruby
&. stops at nil; fetch raises rather than returning nil when a key is genuinely required.
Inspect a TLS certificate from the command line
Networking
Prints the subject, issuer and validity dates without opening a browser.
A regular expression for ISO 8601 dates
Text Processing
Matches a date, optionally with a time and a zone. Deliberately strict about separators.
Security headers for an Express app
Security
The handful worth setting even when you are not using a framework that sets them for you.
Type a fetch response safely
TypeScript
unknown forces a parse step rather than letting an any spread silently through the codebase.
Hash and verify a password in PHP
PHP
password_hash picks the algorithm and the salt. Never store anything a hash function can reverse.
Which DNS records does a domain have?
Networking
dig with +short strips everything but the answer.