Git checkout local repo from N days ago

git checkout @{two.days.ago}

If only there were a way to checkout files from the fuyoocha.

git checkout @{two.days.fromnow}

or maybe

git checkout @{two.days.aftercompleting}

Archive and delete a git branch

Head to the top of the git repository.

$ cd path/to/repo/top

Check out the branch you want, pull, update, whatever to put it into the state you want to archive.

$ git co branch-to-archive
$ git up
$ git pull
$ git whatever

Run this to archive the branch

$ git archive branch-to-archive | gzip > ../some/archive/path/repo-name-branch-name.YYMMDD.tar.gz 

Check the repo is what you want:

$ tar tvfz ../some/archive/path/repo-name-branch-name.YYMMDD.tar.gz | less

Delete the branch remotely and locally:

$ git push origin :branch-to-archive
$ git branch -D branch-to-archive

And, of course, I have this in a script.

Search for a string in all git branches

Yay, git grep!

git grep "string/regexp" $(git rev-list --all)

I love that it works with regular expressions, too.

Ignore .git directories in Apache DOCROOT

Put this in a VirtualHost config block to make sure git files aren't served by the Apache process:

<Directorymatch "^/.*/\.git/">
Deny from all

Won't work in an .htaccess file.