tags:

views:

50

answers:

2

Hi all,

I have multiple projects that I'd like to put up onto GitHub.com. All of these projects are in my local Git repository. I have just one repository, but for each project, I'd like to have 1 GitHub project. That way, bugs can be organized by the project.

How can I set this up so that it isn't that difficult to manage? Do I need to redo my repository layout and create new git repositories locally for each project? That would be really time involved and I might be losing the Git history.

Walter

A: 

If I'm understanding the question, you've got one large repo that contains a number of projects. You would like to break each of those projects out into individual repos without losing history. Bottom line is yes, you have to redo your repository layout and create new git repositories for each project. You don't need to lose history, though.

  1. Make a copy of your current repo, one copy for each sub project.
  2. In each of the new repos, delete all other projects except for the one associated with that repo.

You'll still have all the history prior to breaking the original repo up, but now each project is it's own repository.

If you don't mind losing your history, making each project into it's own git repo is as simple as running git init in the project directory. This will create a new repo for just that project.

kubi
That makes sense. I think what I'll do is do the latter, git init for each project. When I am ready to publish that to github, I want to have a relatively clean codebase ...
+1  A: 

Depending on how your repo is organized, you can use git filter-branch to create a new repo for each project, retaining history for each individual project only.

Assuming your current repo structure is like this:

repo/
  project1/
    project1-file
  project2/
    project2-file
  project3/
    project3-file

You can first clone your repo (git filter-branch will remove files and their history, so clone your original repo first). Then, in your cloned repo, you can use git filter-branch to create a new repo (with all the old history) at the root of project1:

$ git filter-branch --subdirectory-filter project1 HEAD

Now, your repo will look like the following:

repo/
  project1-file

And it will still contain the history for all files that were stored under project1/ in the old repo.

Repeat that step for each project, and you will now have three independent repos, with all the history for their relevant projects.

mipadi
Thanks, that looks like exactly what I want.