Skip to content

Instantly share code, notes, and snippets.

@zosiu
Last active August 29, 2015 14:22
Show Gist options
  • Save zosiu/790bd8b791916e840918 to your computer and use it in GitHub Desktop.
Save zosiu/790bd8b791916e840918 to your computer and use it in GitHub Desktop.
git post-checkout branch logging
git config --global init.templatedir '~/.git-templates'
mkdir -p ~/.git-templates/hooks
  • create ~/.tig-brother/checkouts.db (sqlite3) from the dump

  • copy the hook script

  • git init in the git repo

PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE checkouts(
checkout_at DATETIME NOT NULL,
directory TEXT NOT NULL,
branch_name TEXT NOT NULL
);
COMMIT;
#!/bin/sh
sqlite3 ~/.tig-brother/checkouts.db "insert into checkouts (checkout_at, directory, branch_name) values(datetime('now', 'localtime'), '`pwd`', '`git symbolic-ref -q --short HEAD`')"
echo "tig brother is watching you"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment