I have a repository within a subdirectory, and now I would like to have the parent directories
under version control too, but keep the current history of the repository.
So with the following tree:
a/b/c
c is currently holding a repository, but I would like to have a repository in a, and include all the history within c.
I’m sure there is a way to go around doing this, perhaps with some git filter-branch? I do not want to use submodules, I would like to have a single repository in the end.
You have a choice:
You can simply move the current structure into what will be the new structure. Then move the whole repo a level up.
git add -Awill add all the changes which is a bunch of deletions and new file adds.git statuswill show them as moved. Each object is stored once, no matter what path it’s on so this won’t be an expensive operation. This would be the simplest option. At this time you can also put in the other high level directories.while in c:
git will determine the fact that a file was moved if you are doing merges and help you.
Or, you can use filter branch to change history if you like, but all your commits will have different SHA1s. This may be undesireable.