If you’re a fan of science (or science fiction), you may be familiar with the concept of the “Multiverse”, the idea that there are multiple universes. In some science fiction stories, one universe can split, branching into multiple universes and then later collapse into a single universe, this is a surprisingly good analogy for Git and branching.
When I’m writing examples, it is often nice to have very short commit hashes. The ‘–abbrev=4’ argument, passed after the ‘–oneline flag, allows me to reduce the number of characters in the commit to 4.
When linking to specific lines in a file to GitHub, it is preferable to link to those lines in the file for a specific commit (rather than for a specific branch). This is because the contents of a branch can change but the contents of a commit remain the same forever.
When reading an article online, I find it helpful to know when the article was last updated. Not all blogs display the last updated value however even when the last updated value is not displayed, the value is accessible via the WordPress REST API. This is how I retrieve the last modified value from the WordPress REST API.
I find there are two different times I want to get the current branch name: 1. When I’m at the command line, 2. Inside a Git alias function I’m writing. Interestingly, I find that my approach in these two situations are different.
When running phpcs with the –ignore option (because I don’t want to scan the /vendor nor /node_modules directories), I kept getting the error “zsh: no matches found: –ignore=/vendor/*,/node_modules/*”.
There are lots of ways to name Git branches. These are my personal rules I’ve developed for naming Git branches.
This situation often arises for me when I’m reviewing a teammate’s Pull Request and they make changes by rewriting history. In this situation, I want to discard my local copy of the Pull Request branch and replace it with the version on GitHub (or wherever the remote branch is being stored).
When developing a WordPress plugin that creates a Gutenberg block, it is invaluable to be able to view the attributes on the block. Here are some tricks I use to view this information.