Skip to content

Instantly share code, notes, and snippets.

View jafischer's full-sized avatar

Jonathan Fischer jafischer

View GitHub Profile
@jafischer
jafischer / gist:5b9f69d684d197d41826b54fd33d4ed8
Last active February 26, 2024 19:48
The pre-commit git hook that I can't live without.
#!/bin/bash
main() {
init
# Check that we're not committing directly into the default branch by mistake.
check_branch
# Get the list of staged files once, to save invoking the same command over and over again.
get_staged_files
# Check for "don't commit" comments.
@jafischer
jafischer / git-copydirwithhistory.sh
Created March 15, 2019 16:56
Copy a directory from one git repo to another, preserving history.
#!/bin/bash
# Inspired by http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/
# Author: Jonathan Fischer
# Define some colors first:
black='\x1b[0;30m'; red='\x1b[0;31m'; green='\x1b[0;32m'; yellow='\x1b[0;33m'; blue='\x1b[0;34m'; pink='\x1b[0;35m'; cyan='\x1b[0;36m'; grey='\x1b[0;37m';
BLACK='\x1b[1;30m'; RED='\x1b[1;31m'; GREEN='\x1b[1;32m'; YELLOW='\x1b[1;33m'; BLUE='\x1b[1;34m'; PINK='\x1b[1;35m'; CYAN='\x1b[1;36m'; WHITE='\x1b[1;37m'
NC='\x1b[0m' # No Color