Here is what I have - a git repo of my code:
projects
|-proj1 (no git repo here yet)
|-subproj1 <- current git repo here
Here is what I want - a git repo which is now tracking a new project that uses my code:
projects
|-proj1 <-git repo moved to here, but still tracking files in subproj1
|-subproj1 (no git repo here)
I'd like to keep the history intact and therefore the new repository will be referring to files that are one level deeper than the original. What is the most pain free way to do this?
Just create the directory structure you want inside the repo - i.e. move all files and folders to "subproj1" folder.
Then stage all added and deleted files and git will work out that they are in fact renames:
Rewriting history can be done with the
git filter-branch
command. In fact, moving a directory tree into a subdirectory is one of the cut&paste-ready examples given in thegit filter-branch
manpage: