如何更改删除+添加移动到git历史记录中 [英] how to change remove+add to move in git history

查看:170
本文介绍了如何更改删除+添加移动到git历史记录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个git仓库,它是一些旧的svn仓库的组合。当我混合一切我没有意识到做混帐MV而不是只是移动文件,所以现在大多数文件的svn历史记录丢失。有没有办法解决这个问题?

i have a git repository that is a mix of some old svn repos. when i mixed everything i didn't realized to do git mv instead of just moving the files so now the svn history for most of the files is lost. is there a way of fixing this?

旧的结构是这样的:

the old structure was something like:

svn1
|_apps/
|_tests/
|_...

svn2
|_src
|_libs

svn3
|_src
|_libs

和现在:

   root
   |_libs
   |  |_svn1_name
   |  |  |_apps
   |  |  |_tests
   |  |  |_...
   |_addons
   |  |  |_svn2_name
   |  |  |  |_src
   |  |  |  |_libs
   |  |  |_svn3_name
   |  |  |  |_src
   |  |  |  |_libs

我已经尝试过检查前一次提交给此mv,执行git mv,创建一个新的分支和重新设计大师反对,但结构有点复杂,合并是一种痛苦。有没有更简单的方法来做到这一点?

i've tried doing checkout to the previous commit to this mv, doing git mv, creating a new branch and rebasing master against that but the structure is kind of complex and the merge is a pain. is there an easier way to do this?

推荐答案

通常情况下,Git不跟踪重命名,加。当在同一个提交中发生这种情况时,Git可以快速推断重命名已经完成,并在 git log 中适当地显示重命名。但是,如果删除和添加同一文件发生在不同的提交中,则需要使用 - find-copies-harder 开关 git log

Normally, Git doesn't track a rename any differently than a delete and an add. When this happens within the same commit, Git can quickly infer that a rename was done and show the rename appropriately in git log. However, if the delete and add of the same file happen in different commits, then you need to use the --find-copies-harder switch of git log:


- 查找副本更难


出于性能方面的原因,默认情况下,只有在相同变更集中修改副本的原始文件时, -C 选项才会查找副本。该标志使命令检查未修改的文件作为复制源的候选项。对于大型项目来说,这是一项非常昂贵的操作,因此请谨慎使用。给予多个 -C 选项同样有效。

For performance reasons, by default, -C option finds copies only if the original file of the copy was modified in the same changeset. This flag makes the command inspect unmodified files as candidates for the source of copy. This is a very expensive operation for large projects, so use it with caution. Giving more than one -C option has the same effect.


这篇关于如何更改删除+添加移动到git历史记录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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