6

Possible Duplicate:
How to move files from one git repo to another (not a clone), preserving history

I followed the steps at

How to move files from one git repo to another (not a clone), preserving history

and I did get the files moved over, but it brought the ENTIRE history of the repo with it!

Is there a way to do the same thing but only bring the history of the associated files rather than the entire history of the repository?

Edit:

To be more explicit about what I'm trying to do, assume there are 10 files in a repository and each one has 1 commit associated with it (so 10 total commits in the log).

I have a new repository that I want to transfer some of the files over to, let's say 2 of them. I want to bring the files over with the history from just those files, so I would expect 2 commits from the original repo in the log of the new repo. The method used above brings all 10 commits over, even though only 2 files came over.

Community
  • 1
  • 1
tpg2114
  • 14,112
  • 6
  • 42
  • 57

2 Answers2

0

Have you tried Subtree Merging?

Subtree Merging The idea of the subtree merge is that you have two projects, and one of the projects maps to a subdirectory of the other one and vice versa. When you specify a subtree merge, Git is often smart enough to figure out that one is a subtree of the other and merge appropriately.

We’ll go through an example of adding a separate project into an existing project and then merging the code of the second into a subdirectory of the first.

gcochard
  • 11,408
  • 1
  • 26
  • 41
twaggs
  • 3,591
  • 1
  • 14
  • 8
  • 1
    That doesn't seem to preserve the history of the imported files. Git blame shows all of the merged files as being edited by me, rather than the original author. And the git log doesn't show any of the commits that are related to the files brought over. – tpg2114 Dec 09 '11 at 23:55
  • that link is dead already. Up to date is http://git-scm.com/book/ch6-7.html – sukhmel Jan 05 '14 at 14:09
-7

If the history is only one commit, why not just commit that file in the new repo? There is no history at this point.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • 2
    That was just an example to clarify the point. I'm trying to bring over 2 files from a repo with 1000+ files and 3 years of history. That's why I'm trying to avoid bringing the entire history of the original repo along, I only want the history of the files I bring over. – tpg2114 Dec 10 '11 at 05:22
  • Then just branch for each active branch in the new repo and commit what exists at that point in time. Make a root commit that is common to all branches you want. – Adam Dymitruk Dec 12 '11 at 04:16