过滤分支去除额外的目录 [英] filter-branch to remove extra directory

查看:110
本文介绍了过滤分支去除额外的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将几个Subversion版本库迁移到Git,但它们的设置有些不可思议:标准的trunk / branches / tags结构存在于版本库的几个子目录中。 / branches和/ tags都是空的,所以git-svn导入只以trunk目录结束。

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.

svn/
  proj1/
    trunk/
      src/
  proj2/
    trunk/
      src/

我想用 git filter-branch 删除额外的中继文件夹,但保留其余的中间文件夹:

I would like to use git filter-branch to remove the extra trunk folders but leave the rest intact:

svn/
  proj1/
    src/
  proj2/
    src/

根据上一个文档中的示例,这是我迄今为止:

Based on the last example in the documentation, this is what I have so far:

git filter-branch --index-filter \
    'git ls-files -s | sed "s-/trunk/-/-" |
        GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
            git update-index --index-info &&
     mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD

在我看来,

It seems to me that the sed is doing its job, as this input:

100644 fa3dcf79717e9aca85ad745078a2fb2a2ce2b900 0       proj1/trunk/src/file1.txt

生成此输出:

100644 fa3dcf79717e9aca85ad745078a2fb2a2ce2b900 0       proj1/src/file1.txt

但是,当我运行整个命令时,出现以下错误:

However, when I run the whole command, I get the following error:

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 &&
         mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"

任何想法?我在Windows上使用git 1.7.3.1.msysgit.0。

Any ideas? I'm using git version 1.7.3.1.msysgit.0 on Windows.

更新:现在使用git版本1.9.0.msysgit。 0,类似的情况会产生不同的错误(注意 .git-rewrite 在执行该命令之前不存在):

Update: Now using git version 1.9.0.msysgit.0, a similar situation yields a different error (note .git-rewrite does not exist before executing the command):

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

p>

推荐答案

基于评论此处。 git-svn代表空(仅限目录)提交似乎是个问题。它工作正常,如果我开始在一个正常的提交:

Figured it out based on a comment here. It seems to be an issue with how git-svn represents "empty" (directory-only) commits. It works fine if I start at a normal commit:

git filter-branch --index-filter \
    'git ls-files -s | sed "s-/trunk/-/-" |
        GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
            git update-index --index-info &&
     mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' 83df928c..HEAD

这篇关于过滤分支去除额外的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆