简体   繁体   中英

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. 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. 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. There will be a structure like this in the tag.

  • src

    • CodeFiles1
    • CodeFiles2
    • CodeFiles3
  • 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...

  • CodeFiles1
  • CodeFiles2
  • CodeFiles3

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). 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. 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

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)

git mv -k *./src

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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