3 ms·
> copying files within a repo while preserving file history (if you just copy+paste you lose, if you edit the files after moving with git mv, but before comitti
by Izkata 2y ago
> copying files within a repo while preserving file history (if you just copy+paste you lose, if you edit the files after moving with git mv, but before comitting the move first, you lose all history)
This is much closer a description to svn (and probably other systems), and doesn't describe git at all. Git doesn't store file renames. It reconstructs them from the history based on how similar an "add" and a "delete" were in the same commit. There's even args to change the sensitivity and look for line sources in even broader scopes* - which means git can do one thing others can't, show you where lines came from when two or more files were merged. Others can only show you one of the source files, the one that was explicitly renamed.
* See "-C" in "git help blame", the broadest scope even looks for the source in other commits.
- g-b-r 2y agoExcept that it can't, and doesn't, always work
- bboygravity 2y agoExactly. I have never ever had an OS "cut-paste" operation work in a way that git didn't see as entirely new files that it never saw before. If it did work like that, there would be no reason whatsoever for the "git mv" command to exist.