tags:

views:

105

answers:

2

I currently have a git repository that I imported from svn a while ago name school. Inside this school repository I have a folder for each of my classes.

I can't seem how to take this one repository and split it into a repository for each class without losing the entire history of the class, which I would prefer not to do.

Suggestions?

A: 

Run the following command

git log -u <path>

This will give you a list of changesets (including diff) for each changeset in the specified folder.

From here, you can write a script to parse that output of git log and run each patch on a new repository, keeping the changesets and author info.

Bit of a hack, but it will work.

Zoomzoom83
There has got to be a better way of doing this than that. I have five years worth of commits...
icco
+4  A: 

git filter-branch is the way to go. Make a copy of the repo for each subdirectory, then in each copy run a line like this replacing "myclassname" with your actual class name:

git filter-branch --subdirectory-filter myclassname -- --all
rq
This worked beautifully thanks. I turned it into a shell script which you can see here: http://github.com/icco/git-explode
icco
Nice one, glad I helped :-)
rq
It's spelled "separate".
jleedev
Perhaps also '--remove-empty' to remove commits which do not touch 'myclassname' subdirectory... unless it is turned on by '--subdirectory-filter'.
Jakub Narębski
The flag is --prune-empty - it isn't turned on with the subdir filter.
rq