Skip to content

Instantly share code, notes, and snippets.

View scollett's full-sized avatar

Charlie Collett scollett

View GitHub Profile
#!/bin/bash
# By https://gist.github.com/pixelhandler
# Modified by https://gist.github.com/vistik
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
@scollett
scollett / git_shortcuts.md
Created February 21, 2014 18:34
Tibits of git.fu that are helpful

Removing a file/folder from git git filter-branch --prune-empty --tree-filter 'git rm -rf --cached --ignore-unmatch FOLDER_OR_FILES_TO_REMOVE' --tag-name-filter cat -- --all git filter-branch --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch FOLDER_OR_FILES_TO_REMOVE' --tag-name-filter cat -- --all rm -rf .git/refs/original/ git reflog expire --expire=now --all git gc --aggressive --prune=now

@scollett
scollett / gollum.config.ru
Last active July 20, 2017 07:38
A lightweight author identification for Gollum wiki (with some preferences). Use config.ru to run Gollum as a rack application. Basic HTTP Authentication is commented out.
#!/usr/bin/env ruby
require 'rubygems'
require 'gollum/app'
gollum_path = File.expand_path(File.join(File.dirname(__FILE__), 'database.git')) # CHANGE THIS TO POINT TO YOUR OWN WIKI REPO
Precious::App.set(:gollum_path, gollum_path)
Precious::App.set(:default_markup, :markdown) # set your favorite markup language
Precious::App.set(:wiki_options, {:live_preview => false, :universal_toc => false, :user_icons => 'gravatar'})
module Precious
class App < Sinatra::Base
# Creates a simple authentication layer
@scollett
scollett / remove_file_or_folder_from_git.txt
Last active December 19, 2015 03:18
I had to permanently remove a ginormous folder of seed data from the git repository history (moved it outside the project). I combined advice in several posts on removing folders/files till it worked. I'm not sure if you need all those parameters to both the tree and index filter, but it worked. *Note, be careful if you've already pushed to a sh…
git filter-branch --prune-empty --tree-filter 'git rm -rf --cached --ignore-unmatch FOLDER_OR_FILES_TO_REMOVE' --tag-name-filter cat -- --all
git filter-branch --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch FOLDER_OR_FILES_TO_REMOVE' --tag-name-filter cat -- --all
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --aggressive --prune=now