2

I have some files that exist in a directory in Repo 1. Let's say its a video playback feature. All the file relevant to this feature were not created in this directory. Sometimes developers will realize that commonality and move all the files into a common location.

Now we have a core library where we want all these files to live so they can be reused by other projects. I have successfully used the following commands to get the files into the other repository but it is missing the history of the files before they were moved in Repo 1 to a common directory.

How can I go about doing this such that the file's entire history would be included in the core library regardless of how many times it was git mv'd in Repo 1?

cp -R  repo-where-feature-exists/ video-filtered-repo
cd video-filtered-branch
git remote rm origin 
git filter-branch --subdirectory-filter src/main/resources/static/video-poc/js/video/ -- --all 
rm -rf src/
mkdir -p component-library/src/main/resources/components/video
git mv -k * component-library/src/main/resources/components/video/
git commit -m "Moving files from where they were in the original location into the core location"


Now go to core…
cd /software/dp/core
git remote add video-feature /software/dp/video-filtered-repo/
git pull video-feature integration
Adam Parrish
  • 439
  • 1
  • 5
  • 13
  • 1
    I think this was covered here: http://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories/1425914#1425914 Looks to me like the step you're missing is to use `git filter-branch` to rewrite the history to the exact directory structure you want, rather than doing it separately by `git mv` (which merely removed the files and adds them again, breaking the neat history.) – Eliot Dec 15 '12 at 00:54

1 Answers1

0

See these GitHub help instructions on "Splitting a subpath out into a new repo".

Kirby
  • 2,847
  • 2
  • 32
  • 42
Nils Werner
  • 34,832
  • 7
  • 76
  • 98