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

Re: Problem using git-filter-branch to move tree when repository name contains space

From
Jeff King <peff@peff.net>
Date
Apr 1, 2011, 14:41 UTC
Message-ID
<20110401144107.GA3103@sigill.intra.peff.net>
In-Reply-To
<4D95E182.6030903@revelate.com>
On Fri, Apr 01, 2011 at 04:30:26PM +0200, Jean-François Burdet wrote:
Show 16 quoted lines
> I want to move my repository (wich is contained in a directory whose
> name's containing a space)  root tree to a subdirectory.
> 
> I followed what's documented in
> http://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html ,
> using the last example :
> 
> [...]
>
> jfburdet@nagios:~/git test$ 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
> Rewrite 3658e305df3ace21d39bf57dd4e0e5627818dfcc (1/1)mv: target
> `test/.git-rewrite/t/../index' is not a directory

The problem is that GIT_INDEX_FILE is an absolute path that contains the repo name. So it needs to be quoted in the mv command. This should work:

  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
-Peff
Previous: Jean-François BurdetNext: Jeff King
Message 2 of 4 in “Problem using git-filter-branch to move tree when repository name contains space”
  1. Jean-François BurdetApr 1, 2011
  2. Jeff KingApr 1, 2011
  3. docs: fix filter-branch subdir example for exotic repo namesJeff King, Apr 1, 2011
  4. Jean-François BurdetApr 1, 2011

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.