Note that there are some explanatory texts on larger screens.

plurals
  1. POfilter-branch to remove extra directory
    primarykey
    data
    text
    <p>I'm migrating several Subversion repositories to Git, but they were set up a bit weird: the standard trunk/branches/tags structure lives within several subdirectories of the repository. /branches and /tags are both empty, so the git-svn import ended up with only the trunk directories.</p> <pre><code>svn/ proj1/ trunk/ src/ proj2/ trunk/ src/ </code></pre> <p>I would like to use <code>git filter-branch</code> to remove the extra trunk folders but leave the rest intact:</p> <pre><code>svn/ proj1/ src/ proj2/ src/ </code></pre> <p>Based on the last <a href="http://git-scm.com/docs/git-filter-branch#_examples" rel="nofollow noreferrer">example in the documentation</a>, this is what I have so far:</p> <pre><code>git filter-branch --index-filter \ 'git ls-files -s | sed "s-/trunk/-/-" | GIT_INDEX_FILE=$GIT_INDEX_FILE.new \ git update-index --index-info &amp;&amp; mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD </code></pre> <p>It seems to me that the <code>sed</code> is doing its job, as this input:</p> <pre><code>100644 fa3dcf79717e9aca85ad745078a2fb2a2ce2b900 0 proj1/trunk/src/file1.txt </code></pre> <p>Produces this output:</p> <pre><code>100644 fa3dcf79717e9aca85ad745078a2fb2a2ce2b900 0 proj1/src/file1.txt </code></pre> <p>However, when I run the whole command, I get the following error:</p> <pre><code>Rewrite e00c119cfb755f741dc0e17c36d36bc2ddd27562 (1/42)mv: cannot stat `/c/dev/R epo/.git-rewrite/t/../index.new': No such file or directory index filter failed: git ls-files -s | sed "s-/trunk/-/-" | GIT_INDEX_FILE=$GIT_INDEX_FILE.new \ git update-index --index-info &amp;&amp; mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE" </code></pre> <p>Any ideas? I'm using git version 1.7.3.1.msysgit.0 on Windows.</p> <p><strong>Update:</strong> Now using git version 1.9.0.msysgit.0, a similar situation yields a different error (note <code>.git-rewrite</code> does not exist before executing the command):</p> <pre><code>rm: cannot remove `c:/Path/to/svn/.git-rewrite/revs': Permission denied rm: cannot remove directory `c:/Path/to/svn/.git-rewrite': Directory not empty </code></pre> <p>The same fix ultimately worked.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload