Can Git really track the movement of a single function from 1 file to another? If so, how?

前端 未结 5 1963
予麋鹿
予麋鹿 2020-12-04 11:47

Several times, I have come across the statement that, if you move a single function from one file to another file, Git can track it. For example, this entry says, \"Linus sa

5条回答
  •  难免孤独
    2020-12-04 12:41

    There's git diff that will show you that certain lines disappeared from foo and reappeared in bar. If there are no other changes in these files in the same commit, the change will be easy to spot.

    An intellectual git client would be able to show you how lines moved from one file to another. A language-aware IDE would be able to correspond this change with a particular function.

    A very similar thing happens when a file gets renamed. It just disappears under one name and reappears under another, but any reasonable tool is able to notice it and represent as a rename.

提交回复
热议问题