SVN到Git迁移后重命名中继文件夹 [英] Renaming trunk folder after SVN to Git Migration

查看:89
本文介绍了SVN到Git迁移后重命名中继文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有30个项目,我从SVN迁移到了Git.

I have 30 some projects which I migrated to Git, from SVN.

但是,当我浏览文件夹结构时,我仍然在每个项目中看到Trunk文件夹.有没有一种方法可以自动快速删除它?

However, when I browse the folder structure, I still see the trunk folder there in each project. Is there a way to remove this quickly and automatically?

这是我的svn文件夹结构,请注意,存储库本身没有主干,但是项目具有主干:

Here is my svn folder structure, note that the repository itself does not have trunk, but the projects do:

--MyRepository
  --Project1
    --trunk
      -- files
  --Project2
    --trunk
      -- files
  --Project3
    --trunk
      -- files
  --Project4
    --trunk
      -- files
  --Project5
    --trunk
      -- files
  -- ..

这就是我想要的Git存储库中的内容:

And this is what I want in my Git repository:

--MyRepository
  --Project1
    -- files
  --Project2
    -- files
  -- ..

谢谢.

PS::我以为可以共享用于迁移的命令.就这样了:

PS: I thought I could share the commands which I use to migrate. There it goes:

mkdir gitRepo && cd gitRepo
git svn init http://bla/svn/myRepo --no-metadata
git config svn.authorsfile ../authors.txt
git svn fetch

推荐答案

所以,就到这里了.

执行魔术的命令是:

git filter-branch -f --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"' af117ec86a30ba6676571cd1f73083c5cfbec0bd..HEAD

请注意在..HEAD之前的提交标签,该标签应该是您应该输入的第二或第三最早的提交标签.如果输入第一个,则会出现错误.

note the commit tag before ..HEAD, that should be either second or third earliest commit tag that you should enter. If you enter the first, you get an error.

要找出最早提交的commit标签,只需使用:

To find out the commit tag of the earliest commit, simply use:

git log

并尽可能向下滚动,您将在其中看到最早的提交.拿第二或第三.完成了.

and scroll down as much as you can, there you will see the earliest commits. Take the second or third. It's done.

这篇关于SVN到Git迁移后重命名中继文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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