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

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

Repo Bloat: Finding Large Objects

I’ve written previously about trimming the fat on bloated Git repositories. Here I’ll present a convenient method for listing the largest objects in a human-friendly format. The first step in finding the largest objects is to list all objects. We can do this with verify-pack: $ git verify-pack -v .git/objects/pack/pack-{HASH}.idx 8306276cde4f3cff8cbe5598fd98bf10146da262 commit 254 170 9725 4677b7c11924cefa62393f0e3e7db6c06787815e tree 30 63 9895 1 08ce30d6550bed7725c399026d91fce24c86a79f 5062bde76952965ff5c473a7de0ae102b4d2c9f3 tree 1122 944 9958 1c1ef555c77ee527c95ca093f251313a6418c158 blob 10 19 10902 non delta: 15175 objects chain length = 1: 1672 objects chain length = 31: 10 objects chain length = 32: 4 objects ....

2015-11-17 · 3 min · 615 words · Nathaniel Hoag

Automating Drupal Module Deployment with Ruby

After building a bash script to automate Drupal module deployments, I figured it might be worthwhile to convert the script over to Ruby. I decided to spin up the new version as a Ruby gem leveraging the Thor CLI Framework. Having already worked out many of the mechanics of deploying Drupal contrib modules in the previous bash script, I was able to dive right into coding. I started by fleshing out the command options and then moved into scripting the functionality....

2014-05-21 · 3 min · 550 words · Nathaniel Hoag