Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lost git history after reorganizing project folder

Tags:

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.

like image 776
refulgentis Avatar asked Nov 14 '10 08:11

refulgentis


2 Answers

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

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.

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.

like image 169
Gian Marco Avatar answered Sep 28 '22 05:09

Gian Marco


As far as I see it you want:

git log --follow some_file.cpp 

See http://git-scm.com/docs/git-log for details. I am not sure if that is what you want; but in case of git, git tracks content not files. The problem is that determining that information is really expensive and it is assumed that normally you don't need it...

like image 40
rioki Avatar answered Sep 28 '22 06:09

rioki