Converting file (tracked with Git) from Java to Kotlin in Android Studio

前端 未结 4 2235
梦毁少年i
梦毁少年i 2021-02-12 04:50

A conversion from Java to Kotlin in Android Studio 2.3.2 (in 3.0 the same behaviour) creates a new file and deletes previous. So Git doesn\'t know anything about this conversion

4条回答
  •  一生所求
    2021-02-12 05:32

    Git guesses renames from added/removed file pairs, but only if these files are close enough, i.e. if the file was renamed with no or small amount of changes.

    When you apply java-to-kotlin conversion usually every line of a file changes, so that git cannot find that these old and new files somehow relate to each other.

    You can use the following two-stage approach instead:

    • just change the extension of .java file to .kt and commit it;
    • rename it back, apply the conversion and commit the modified .kt file.

提交回复
热议问题