gitversion-control

Lost git history after reorganizing project folder


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.

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.


Solution

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

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

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

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