Protecting Git Branches

I’ve been thinking about the vulnerability of the primary Git branch for the last several weeks. Mostly out of paranoia about destroying a critical application. I added protective measures to my local clones on important projects and was content in thinking that I was now safe. But today I was reminded that this is only a small part of protecting a collaborative project. Here’s what happened: User 1 made a commit on master and pushed to origin User 2 fixed a bad merge on branch feature and ran git push --force User 1 made a tag directly on the remote and deployed to Production User 1 saw the new tag in production, but the new commit was missing The problem was introduced with the git push --force....

2016-09-15 · 2 min · 356 words · Nathaniel Hoag

Exciting Dotfile Enhancements

Over the weekend, I’ve been cleaning up, organizing and improving my dotfiles. Below are a couple of things that I’m most excited about. Zsh in Vim Mode I’ve been using zsh for a while, but only recently starting using zsh in Vim mode. One thing that’s been sorely missing is moving by word in INSERT mode. I got this working by adding the following to ~/.zshrc: bindkey '^b' backward-word bindkey '^w' forward-word With this config loaded, I can move forward by word boundaries with Control-w and backward with Control-b....

2016-09-11 · 2 min · 261 words · Nathaniel Hoag

Execute Multiple Commands in Vim

Today I needed to perform multiple transforms on a chunk of text in a file and found a nice solution in Vim! Initially I was thinking about VISUAL mode in Vim and chaining transforms the way I would do with sed (i.e. s/one/two/g;s/^/ /;s/$/,/). It turns out this doesn’t exactly work in Vim, but it’s not too far off the mark. The following syntax works in Vim NORMAL mode: :%s/^/ / | %s/string/replace/g | %s/$/,/ And in VISUAL mode, the sytax is slightly different....

2016-09-08 · 1 min · 103 words · Nathaniel Hoag

Signing Commits in Git

There are some great resources for getting set up with signing Git commits and tags with a GPG key: https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work https://help.github.com/articles/signing-commits-using-gpg/ After following instructions, I still got the following error: error: gpg failed to sign the data fatal: failed to write commit object Below is a sequence of commands that got everything working properly: # Assumes homebrew and existing key-pair brew install pinentry-mac # Get the secret key value gpg2 --list-secret-keys | grep ^sec git config --global user....

2016-09-05 · 1 min · 133 words · Nathaniel Hoag

Helpful Tidbits

Below is a smattering of helpful tidbits from the last several months. less Case-insensitive search: Add -i to your LESS environment variable Drupal Hide fieldgroups with all child fields: field_group_hide_field_groups($form, array('field_group_name')); OS X “Disable” the dock by setting a long autohide delay: defaults write com.apple.dock autohide-delay -float 5 Clear the clipboard: pbcopy </dev/null wc Consider the following: # 'HELLO' + newline echo HELLO | wc -m 6 # Just 'HELLO' echo -n HELLO | wc -m 5 Google Hangout Toggle camera: ⌘ + e Toggle microphone: ⌘ + d Much better than using a mouse!...

2016-09-04 · 1 min · 130 words · Nathaniel Hoag