Reputation: 10908
I have a git repository containing multiple components, each in their own directory. I now want to put each component in its own git repo. A requirement here is that the git history is not lost, so git blame still works. I'm looking for a way to do this and not have unrelated git history. There are two reasons for this: I do not want the repo history to be cluttered with changes to code not part of the component and I like the commit count and other things in the history to be reasonably accurate.
I already looked at this helpful post which goes in the right direction. It however does not remove pointless commits altogether (so now there are a lot of null commits in the history). It also does not retain history for files that got moved from some other component in the past (ion case that component is excluded), or even if they where touched in a commit that also touched files in ignored components.
Is there a better way of doing this?
Upvotes: 0
Views: 99
Reputation: 18520
git filter-branch
has a specialized mode for reducing a repository to a subdir. Check out the option --subdirectory-filter
. It should get rid of irrelevant commits automatically, and it moves the contents of the subdir to the top level of the repo.
However, it does not track/follow file renames. You're looking at a lot of manual work if you want that. After all, you'd have to include changes to the files in their old location but also rewrite the paths to the post-rename location. We don't have anything that ships with git that does this.
Upvotes: 1