2 ms·
'git mv <source> <dest>' works pretty well for this.
by moojd 6y ago
'git mv <source> <dest>' works pretty well for this.
- kccqzy 6y agoIt does not. That's the same as doing a normal mv followed by git add. It does not record the fact that you moved it. You can verify this by moving a file and making big changes to it in the same commit. Git will forget that you moved it.
- TechBro8615 6y agoIf you `git mv`, then immediately commit (without making any additional changes), I think it will recognize it as a move 100% of the time (i.e., will not use its "similarity index"). I'm not certain of that though.
- darekkay 6y agoThat's correct, but this also applies to "move file" + "git add". Just make sure to commit the "move" and "change" parts separately.
- hansvm 6y agoSure, but if you mv and git add without making any additional changes and then immediately commit, it'll also get picked up as a move 100% of the time.