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

Using filter-branch to move repo contents in subdirectory

From
Adam Mercer <ramercer@gmail.com>
Date
Jul 29, 2010, 12:37 UTC
Message-ID
<AANLkTik2dL5jrEjZe0LB6Y4_PEwRt-7t_5CG7gup3pnV@mail.gmail.com>
Hi

I'm trying to use git filter-branch to move all contents of a repo into a subdirectory of the repo root. The git filter-branch man page has the following example:

       To move the whole tree into a subdirectory, or remove it from there:
           git filter-branch --index-filter \
                   'git ls-files -s | sed "s-\t\"*-&newsubdir/-" |
                           GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
                                   git update-index --index-info &&
                    mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
So I've been trying to use this, the original structure of the repo is:

$ ls 00boot SFTdumpall.c debian Makefile.am SFTdumpheader.c ligodcc.cls README SFTvalidate.c pdfdraftcopy.sty SCCB_2004_09_09 SFTwrite.c run_validate.sh SFTReferenceLibrary.c T040164.tex sftreferencelibrary-2.2.tar.gz SFTReferenceLibrary.h configure.in sftreferencelibrary-2.3.tar.gz $

and I want all this in a subdirectory call "sftlib", so using the example from the manpage I ran:

$ git filter-branch --index-filter \
    'git ls-files -s | sed "s-\t\"*-&sftlib/-" |
        GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
            git update-index --index-info &&
    mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
Rewrite 223651f2ebd5d5d9341bcfc9e7cb6caaa3f4d171 (56/65)Ignoring path
00bootsftlib/
Rewrite c979ee835ebb89408e2f5f345ddefbb4d8cd75f5 (57/65)Ignoring path
00bootsftlib/
Rewrite 10037389e41fb4b4d04234ca2e302a7a491616d5 (58/65)Ignoring path
00bootsftlib/
Rewrite 21b4c31a02c6b7718145d471ba20e6fa70eb30d0 (59/65)Ignoring path
00bootsftlib/
Rewrite dc5cebbe14050f52f2effaa5eac4eb579dd440c3 (60/65)Ignoring path
00bootsftlib/
Rewrite 3b83fdd19b5d674445f5263df8cb2fc35c3c0092 (61/65)Ignoring path
00bootsftlib/
Rewrite 5246038ceeb2d28fba462076b62f3cf1b2b7e9ab (62/65)Ignoring path
00bootsftlib/
Rewrite 0fd3256ff401b405c677e83db350ad41ee74ef0d (63/65)Ignoring path
00bootsftlib/
Ignoring path debian/compatsftlib/
Ignoring path debian/copyrightsftlib/
Rewrite 9aca227c807658b951e81a6ca4460115b2fe8ccc (64/65)Ignoring path
00bootsftlib/
Ignoring path debian/compatsftlib/
Ignoring path debian/copyrightsftlib/
Rewrite 00274be10e10920d84db145268d85faf1b06539f (65/65)Ignoring path
00bootsftlib/
Ignoring path debian/compatsftlib/
Ignoring path debian/copyrightsftlib/

Ref 'refs/heads/to_merge' was rewritten $

now the directory structure is:

$ ls Makefile.am SCCB_2004_09_09 SFTReferenceLibrary.h SFTdumpheader.c SFTwritsftlib configure.in ligodcc.cls run_validatsftlib README SFTReferenceLibrary.c SFTdumpall.c SFTvalidatsftlib T040164.tsftlib debian pdfdraftsftlib sftsftlib $

which is clearly not what I'm wanting. What I am doing wrong here? As far as I can I'm using the example from the man-page?

Cheers
Adam
Next: Thomas Rast
Message 1 of 13 in “Using filter-branch to move repo contents in subdirectory”
  1. Adam MercerJul 29, 2010
  2. Thomas RastJul 29, 2010
  3. Adam MercerJul 29, 2010
  4. filter-branch tests/docs: avoid \t in sed regexesThomas Rast, Jul 29, 2010
  5. Tomas CarneckyJul 29, 2010
  6. Thomas RastJul 29, 2010
  7. Tomas CarneckyJul 29, 2010
  8. t7005: fix subdirectory-filter testThomas Rast, Jul 29, 2010
  9. Thomas RastJul 29, 2010
  10. Adam MercerAug 9, 2010
  11. Adam MercerAug 11, 2010
  12. Jeff KingAug 11, 2010
  13. Adam MercerAug 11, 2010

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.