简体   繁体   English

Svn 迁移到 Git - 在 Git 中获取所有已更改文件的状态,因为在创建分支的位置已更改整体路径

[英]Svn migration to Git - Getting a status in Git on all changed files since a branch was created where the overall path has changed

I'm dealing with a migration from SVN to Git.我正在处理从 SVN 到 Git 的迁移。 The problem I have is that I want to be able to get a list of all modified files in a Git branch since that branch was created.我遇到的问题是,我希望能够获得 Git 分支中所有已修改文件的列表,因为该分支已创建。 All of these branches are created off of tags.所有这些分支都是由标签创建的。

This is really simple when there have been no structural changes between the tag and the branch.当标签和分支之间没有结构变化时,这非常简单。 You checkout the branch and then run this command to check for modified files between the branch and the tag.您签出分支,然后运行此命令以检查分支和标记之间的修改文件。

git diff --diff-filter=M --name-only <TAG>

Unfortunately because the repository is migrated from SVN the overall paths have changed in some cases when people created branches off of the tags.不幸的是,由于存储库是从 SVN 迁移的,因此在某些情况下,当人们从标签创建分支时,整体路径已经改变。 There will be a structure like this in the tag.标签中会有这样的结构。

  • src源代码

    • CodeFiles1代码文件1
    • CodeFiles2代码文件2
    • CodeFiles3代码文件3
  • integrationtests集成测试

And in the branch they will have just taken everything out of src and put it in the root so the branch will look like this...在分支中,他们将刚刚从 src 中取出所有内容并将其放在根目录中,因此分支看起来像这样......

  • CodeFiles1代码文件1
  • CodeFiles2代码文件2
  • CodeFiles3代码文件3

In this case Git detects that all of the files are renamed and only displays that as the status (usually R100 is what comes up).在这种情况下,Git 检测到所有文件都已重命名,并且仅将其显示为状态(通常出现 R100)。 If I turn off rename detection then all of the files come up with status of added.如果我关闭重命名检测,那么所有文件都会出现添加状态。

I've tried a few different things, but there seems to be no way around this other than to do the migration from SVN differently and change the paths.我尝试了一些不同的方法,但除了从 SVN 进行不同的迁移并更改路径之外,似乎没有其他办法。 The other option that would probably would would be to just pull two different copies of the repository, check out the tag in one and the branch in the other and then do a local diff, but I was hoping to not have to try that.另一种选择可能是只提取存储库的两个不同副本,检查一个中的标签和另一个中的分支,然后进行本地差异,但我希望不必尝试。

My workaround for this problem was just to move the branch files back into the subfolder and then the diff can identify modified files again.我对这个问题的解决方法是将分支文件移回子文件夹,然后差异可以再次识别修改过的文件。

Create the subfolder in the branch在分支中创建子文件夹

mkdir src mkdir 源代码

Move everything in the root into that subfolder ignoring errors (it will give an error for copying src onto itself, the -k switch just ignores the error skipping the attempt to move src onto itself)将根目录中的所有内容移动到该子文件夹中,忽略错误(将 src 复制到自身时会出错,-k 开关会忽略跳过尝试将 src 移动到自身的错误)

git mv -k *./src git mv -k *./src

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM