Recent work has had me splitting and merging git repositories using git filter-branch to carve down a cloned repo to just the desired file(s). An alternative is to use git format-patch to export the patch series representative of a file’s history.

This approach is outlined perfectly here:

A brief example while working on my qmail-skim project. In this case a source repository contained a file, and I wished to export its history for use in a new standalone repository.

Export patches from a clone of the source repo:

cd /clone/of/repo
git format-patch -o ~/tmp/patches --root scripts/email/

Create a new repository:

cd /somewhere
mkdir qmail-skim
cd qmail-skim
git init
Initialized empty Git repository in /home/hardyjm/tmp/qmail-skim/.git

Import the patchset:

git am ~/tmp/patches/*.patch
Applying: Initial commit of, the configurable qmail-queue filtering replacement.
Applying: -fixed bug debugging...
Applying: -phishhook snagging implemented...
Applying: phishhook snagging implemented
Applying: Fixed bug in phishfrom check...

At the end of the process, the destination repository contains the file and its history.