How does git handle moving files in the file system?

后端 未结 2 374
时光取名叫无心
时光取名叫无心 2021-02-04 04:26

If I move files within a repository, such as from one folder to another, will git be smart enough to know that these are the same files and merely updates its reference to these

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-04 05:24

    The git repository distinguishes files by checksum, not by name or location. If you commit, and then move a file to a different location and commit, the file in the before location and the file in the after location have the same checksum (because they have the same content). Therefore the repository does not store a new "copy" of the file; it merely records the fact that a file with this checksum now has the second location.

提交回复
热议问题