git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git filter-branch --subdirectory-filter

From
James Sadler <freshtonic@gmail.com>
Date
May 9, 2008, 01:01 UTC
Message-ID
<e5e204700805081801x314b02bek5d53a086b02dac83@mail.gmail.com>
Hi All,
I have some issues with git filter-branch.

I have a git repository that I wish to split into multiple seperate repositories for each logical module that it contains. Each logical module is already in its own directory at the root of the repo.

My experiments with 'git filter-branch' have been *partially* successful.

To extract a module into its own repo, I first copied the original repo (this was a simple cp -r, as it seemed to be the simplest way as git clone doesn't get all the branches) and ran filter-branch with a --commit-filter to skip commits that were irrelevant to th subdir.

That step worked just fine.

The next pass was to 'hoist' the contents of the subdir in the new repo into the root dir. I thought I could do this with a --subdirectory-filter argument to filter-branch, except when I do this, I loose tons of commits. (The working tree is correct, i.e. the same as the original repo working tree, but the history is screwed).

Anybody have any idea what I am doing wrong? If it can't be done with --subdirectory-filter can it be done with the 'subtree' merge strategy somehow?

Cheers,
-- 
James
Next: Jeff King
Message 1 of 10 in “git filter-branch --subdirectory-filter”
  1. James SadlerMay 9, 2008
  2. Jeff KingMay 9, 2008
  3. James SadlerMay 9, 2008
  4. Johannes SixtMay 9, 2008
  5. Jeff KingMay 9, 2008
  6. James SadlerMay 10, 2008
  7. Jeff KingMay 10, 2008
  8. James SadlerMay 10, 2008
  9. James SadlerMay 10, 2008
  10. Jeff KingMay 10, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.