Git does not track history after renaming / moving modified file

Problem: I need to change the location of entire directories in the repository. For this, I use git mv, and if necessary, I change the include header names to the appropriate ones at present. The problem is that I take both actions during the same commit. In this situation, there is no history of the file (git consider this to be deleting and creating new files).

Workaround: If I split these actions into separate commits, the problem does not occur.

The problem arises again: However, even when I use the above solution, the problem returns during the merge with the master. I must use f-ff only. In this situation, a new commit for the master branch is made from changes to both commits and ... history does not track properly.

Another ugly workaround: I can deliver these commits separately for mastering. I cannot deliver incompatible code, but if I exclude it from the construction process, it can be doable ... But it is ugly and so wrong ...

I am wondering if there is a better solution to this problem.

+4
source share
1 answer

(VCS), , Git .

, Git . VCS ( VCS). Mercurial : , Mercurial, , Mercurial , . , , , .

Git . Git . Git .

. , . VCS: . Git , , , .

git log --follow , , Git , . Git . , , : , . 1

Git , . :

git diff --find-renames $hash1 $hash2

, , " a/b/c.txt $hash1, , d/e/f.log $hash2", Git , ( , , ). , , Git . . : , . , , . Git - "" , . Git - , -M75% -M50% - Git " " .

- . . " ", " " .., Git . --no-renames, Git ( ).

( , merge git diff --find-rename, , . Git , , , , , . , , , Git , 2.15.)


1 , : , child.txt p1.txt # 1 p2.txt # 2? VCSes , , , , , , , .

0

Source: https://habr.com/ru/post/1690061/


All Articles