From dce3ec1dedca68d7eacdc43d3a17496b5fe21f88 Mon Sep 17 00:00:00 2001
From: tekkub <tekkub@gmail.com>
Date: Sun, 27 Sep 2009 14:44:48 -0600
Subject: Add subpath splitting guide

---
 ...09-27-splitting-a-subpath-to-a-new-repo.textile | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 _posts/2009-09-27-splitting-a-subpath-to-a-new-repo.textile

(limited to '_posts/2009-09-27-splitting-a-subpath-to-a-new-repo.textile')

diff --git a/_posts/2009-09-27-splitting-a-subpath-to-a-new-repo.textile b/_posts/2009-09-27-splitting-a-subpath-to-a-new-repo.textile
new file mode 100644
index 0000000..806943e
--- /dev/null
+++ b/_posts/2009-09-27-splitting-a-subpath-to-a-new-repo.textile
@@ -0,0 +1,28 @@
+---
+layout: default
+title: Splitting a subpath out into a new repo
+description: How to generate a new repo from a subpath, retaining history.
+categories: repos
+---
+
+From time to time you may find that you want to make a new repo from a subpath of an existing repo.  Perhaps you're moving some code out into a library or just want to have a common submodule across projects.  Thanks to git, it's easy to do this without losing the history of that subpath in the process.
+
+h2. The Good Stuff
+
+Splitting a subpath into a repo is a fairly straightforward process, even if the command is hard to remember.  For this example, we split @lib/@ out of the "GitHub gem":http://github.com/defunkt/github-gem repo, removing empty commits but retaining the path's history.
+
+<pre class="terminal">[tekkub@tekBook: ~/tmp] $ git clone git://github.com/defunkt/github-gem.git
+Initialized empty Git repository in /Users/tekkub/tmp/github-gem/.git/
+remote: Counting objects: 1301, done.
+remote: Compressing objects: 100% (769/769), done.
+remote: Total 1301 (delta 724), reused 910 (delta 522)
+Receiving objects: 100% (1301/1301), 164.39 KiB | 274 KiB/s, done.
+Resolving deltas: 100% (724/724), done.
+
+[tekkub@tekBook: ~/tmp] $ cd github-gem/
+
+[tekkub@tekBook: ~/tmp/github-gem master] $ git filter-branch --prune-empty --subdirectory-filter lib master
+Rewrite 48dc599c80e20527ed902928085e7861e6b3cbe6 (89/89)
+Ref 'refs/heads/master' was rewritten</pre>
+
+Now we have a re-written master branch that contains the files that were in @lib/@.  We can simply add a remote to the new repo and push, or do whatever we want with the repo.
-- 
cgit v1.3.1

