Combining multiple git repositories having a space in their name

I tried using the answer involing git-filterbranch from this question Combining multiple git repositories but running in trouble because this answer doesn’t seems to work when repository name having a space in its name.

For example, this wouldn’t work if the repository would be called “my figures” instead of “figures”.

  • git push rejected non-fast-forward
  • Squash my last X commits together using Git
  • How to ignore files using git-gui (tcl-tk) application?
  • “Git Log” command in Powershell - unable to terminate process
  • new git user using netbeans support unable to pull latest commit from remote repository
  • Heroku: how to “git pull” after 'git push -f'
  • I’m running msysgit.

    Here is a sample, with a “my figures” repository, wich is failling :

    /d/git/my figures (master)
    $ git filter-branch --index-filter \
    > 'git ls-files -s | sed "s-\t-&my figures/-" |
    > GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
    > git update-index --index-info &&
    > mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
    Rewrite d9f3a10522f2a0e1531f45e8e7b3a518f0d714c5 (1/1)mv: when moving multiple files, last argument must be a directory
    Try `mv --help' for more information.
    index filter failed: git ls-files -s | sed "s-\t-&my figures/-" |
    GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
    git update-index --index-info &&
    mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE
    rm: cannot remove `d:/git/my figures/.git-rewrite/revs': Permission denied
    rm: cannot remove directory `d:/git/my figures/.git-rewrite': Directory not empty
    

    The, retrying with the repository renamed a myfigures, wich is working fine :

    /d/git/myfigures (master)
    $ git filter-branch --index-filter 'git ls-files -s | sed "s-\t-&myfigures/-" |
    GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
    git update-index --index-info &&
    mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
    Rewrite d9f3a10522f2a0e1531f45e8e7b3a518f0d714c5 (1/1)
    Ref 'refs/heads/master' was rewritten
    

    So, how tweaking this git filter-branch call to support repository name having a space in them ?

  • pull specific commit/file from git
  • Is there a git equivalent to clearcase catcr
  • How to install git on Linux
  • Pull request without forking?
  • Why not check in AssemblyInfo.cs
  • Rollback to an old commit using revert multiple times
  • 2 Solutions collect form web for “Combining multiple git repositories having a space in their name”

    I finally asked the question on the git mailing list: one of the member came with an answer : some quotes should be added to the mv sub-command, they have updated the documentation : see last sample from http://git-scm.com/docs/git-filter-branch

    I believe it should be sufficient to quote the filenames you’re passing into git update-index:

    ... | sed "s-\t-&\"my figures\"-" | ...
    

    Of course, the quoting/escaping would be a little simpler if you put the filter into its own file – this wouldn’t all be surrounded by single quotes.

    Git Baby is a git and github fan, let's start git clone.