如何更改删除+添加以在 git 历史记录中移动
我有一个 git 存储库,它是一些旧的 svn 存储库的混合体。当我混合所有内容时,我没有意识到要执行 git mv 而不是仅仅移动文件,所以现在大多数文件的 svn 历史记录都丢失了。有办法解决这个问题吗?
旧的结构是这样的:
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,创建一个新分支并重新调整 master 的基础,但结构有点复杂,合并很痛苦。有没有更简单的方法来做到这一点?
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
and now:
root
|_libs
| |_svn1_name
| | |_apps
| | |_tests
| | |_...
|_addons
| | |_svn2_name
| | | |_src
| | | |_libs
| | |_svn3_name
| | | |_src
| | | |_libs
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,Git 跟踪重命名与删除和添加没有任何不同。当这种情况发生在同一个提交中时,Git 可以快速推断重命名已完成,并在 git log 中适当地显示重命名。但是,如果同一文件的删除和添加发生在不同的提交中,那么您需要使用
git 日志
: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 ofgit log
:使用 git log --follow 处理单个文件,除了作为添加+删除提交的重命名之外,我还可以跟踪其历史记录
using git log --follow on a single file I can track its history beyond renames that were committed as add+remove