views:

58

answers:

2

For instance, suppose I have Repository 1 and Repository 2. Repository 1 has a file /a/b/c/d. Would it be possible for me to import this file into Repository 2 as /e/f/g/h?

The reason being that I want to pull in changes from an experimental branch from a different git repository. I tried merging everything together, but there were a ton of conflicts (of every kind). Therefore, I doubt that I can merge the entire branch in, but I would like to try to bring in as much as I can.

Is there any way to do what I want to do, or am I just going to have to resort to copying files directly?

+1  A: 

You'll have to copy the file directly. Git deals with whole repositories, not single files within them.

I suppose you could set Repository 2 up as a remote repository, fetch (not pull) its branches, then use git checkout to grab a file out of that branch, but that solution could be messy.

mipadi
+1  A: 

You can get files from the remote repository using git archive. You could then add and commit the files to your repository. This approach will not preserve history from his branch. See git archive docs for details.

If you want to try to preserve parts of that experimental branch, you could git fetch his repository, and then git rebase his experimental branch onto your repository, editing or skipping commits with conflicts as appropriate. Once you have a cleaned up branch in your repository, you can merge that in. See git rebase docs

Jamey Hicks