重新组织项目文件夹后丢失了 git 历史记录 [英] Lost git history after reorganizing project folder

查看:20
本文介绍了重新组织项目文件夹后丢失了 git 历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大约一个月前,我进行了一次提交,其中涉及创建新文件夹和子文件夹并在它们之间移动我的源代码文件.从那时起,我只是第一次查看我的历史记录,并意识到 git 已经丢失"了历史记录,因为原始文件被删除然后重新添加,我想 - 即当我在我的 git GUI 中查看文件时(它是在 NDA 下,所以我不能直接讨论它,但是例如,这个存储库在 GitHub 上也被破坏了.GitHub 清楚地显示它检测提交是一系列动作.)它只显示每个文件的历史记录回到项目文件夹时进行了重组.

I made a commit about a month ago that involved me creating new folder and sub-folders and moving my source code files in between them. I just was looking through my history for the first time since then and realized git has 'lost' history since the original files were deleted and then re-added, I suppose - i.e. when I'm viewing a file in my git GUI (it's under NDA so I can't discuss it directly, but for example, this repository is broken on GitHub too. GitHub clearly shows its detecting the commit as a series of moves.) it only shows history for each file back to when the project folder was reorganized.

阅读几个问题后(让 Git 确认以前移动的文件, 如何让 git 将删除的文件和新文件标记为文件移动?),我只是比开始时更迷茫.从这些答案中听起来我根本无法解决这个问题?我真的很感激这里的任何帮助.

After reading a few questions ( Getting Git to Acknowledge Previously Moved Files, How to make git mark a deleted and a new file as a file move?), I'm simply more lost than when I started. It sounds like from those answers that I won't be able to fix this at all? I'd really appreciate any help here.

推荐答案

在 Git 中没有文件移动的概念.

In Git there's no the concept of file move.

一些工具,如 GitHub,考虑一个提交,其中包含一个名为 X 的文件,该文件已被删除,一个名为 X 的文件已创建并移动.

Some tools, like GitHub, consider a commit containing a file named X that has been deleted and a file named X that has been created a file move.

根据 Linus Torvalds 的说法,文件移动只是重构的一个特例;出于这个原因,Git 不会区别对待它.与许多其他情况一样,这种特殊情况的处理由更高级别的工具(例如前端)来处理.

According to Linus Torvalds, file move is just a special case of refactoring; for this reason Git will not treat it differently. Handling of this special case, like many others, is left to higher-level tools (such as frontends).

有关此主题的更多信息,请查看 这个答案来自 Linus Torvalds.

For more info on this topic, check this answer from Linus Torvalds.

这篇关于重新组织项目文件夹后丢失了 git 历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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