Following GIT moves/renames via version control: log

Answered

GIT does not track moves or renames on commit but uses heuristic to find matching content. However, if the content differences exceed a given treshold, git log will no longer detect the related commits. Adding --follow and a lower treshold via -Mx% "solves" this. Is there a way to do this via intellij? In my specific case I do not see history for such a file in IntelliJ log, but I do see it when running git log --follow -M40

1
8 comments

There is no way to directly change the command-line options issue by IDE. However, there should be no need for this. New file history in 2017.1. should correctly find and follow renames.

What IDE version do you use?

0

I'm having exact same issue, using latest intellij

I have moved some files from one package to the other, git didnt pick them up (so add silently option seems not to work although its enabled)
so it showed that i removed files from old location and have stuff untracked, however when I add untracked files it does not figure out that they are the same files but moved... 




0
Avatar
Permanently deleted user

Is there any news since post was created?

0

If you mean doing additional commit to improve renames detection, it is implemented for java to kotlin conversion, but not for other operations - https://youtrack.jetbrains.com/issue/IDEA-134145

0
Avatar
Permanently deleted user

I experienced the same issue using IntelliJ IDEA 2018.2.6. I needed to rename a package name, but using the rename command from IntelliJ it was loosing all the history of some files. I used this workaround to solve the issue, maybe it is not the cleanest but it saved the history of all files:

1. Instead of renaming the package, I created a new one with the new name

2. I manually copy pasted the files from the old package folder to the new one, without changing the package names in the files

3. I committed the changes

4. I manually renamed the package names in the files (basically search - replace)

5. I committed the new changes

I understand it is not a best practice, but in my case it has been very useful, since I had to change the artifact of a whole big project and didn't want to loose any history.

0

Abbate, please follow the discussion on the duplicate issue: https://youtrack.jetbrains.com/issue/IDEA-143680

Thank you.

0

Having 2021.2.3 Ultimate edition, I still suffer these issues. I have to always put extra care when renaming modules or packages. As for modules, I had to precreate the module with new name manually and then move the stuff there manually. Renaming via refactor dialog looses history.

0

Please sign in to leave a comment.