4

I moved file in my repository and git doesn't detected this as move. It detected that as deleting and adding file. I commited this change and then made many another things. After that I realized that I can't see history of moved file.

I found reason of my mistake and now I want to find how can I fix that.

Is there a way to restore a history of file?

This Viewing GIT history of moved files solution doesn't solve my problem because I don't move my file properly. All history is lost.

2

1 Answer 1

0

First, I think you are misunderstanding renames in git. To git, a file will never be "improperly moved" because git tracks the content rather than the files and file names. The creator of git, Linus Torvalds, says this about renames:

git really doesn't even care about the whole "rename detection" internally, and any commits you have done with renames are totally independent of the heuristics we then use to show the renames.1

So what may actually be happening is that git log --follow is not working for you because --follow only checks for renames of files that are 50% similar by default. However, your file may only be 20% or 30% similar to its renamed version. Try using --find-renames=<n> with different values below 50%, and see if that fixes the issue:

git log --follow --find-renames=35% path/to/your/renamed/file
  1. http://marc.info/?l=git&m=119638337122721&w=2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.