4 ms·
> You can’t rename a file in Git. $ git-mv <old_name> <new_name>
by everybodyknows 4y ago
> You can’t rename a file in Git.
$ git-mv <old_name> <new_name>
- ironmagma 4y agoThat will produce an add plus a deletion. Whether or not this is considered a rename is up to git-diff, via the -M flag which specifies a “similarity index”. Side note, this doesn’t work with LFS-tracked files. But, with regular files you can say, e.g. you want the similarity index to be 50%, and then any files that were deleted that match 50% of their contents with another add will be displayed as a rename. So it’s really just a view thing. In the underlying storage, there is no such thing as a rename.
- seba_dos1 4y agoSee? That's what I was talking about. Learning the UI before learning what it actually does :) This only leads to confusion once you use 'git mv' and edit the file significantly enough in the same commit. "Why doesn't git show that it's a rename? I explicitly told it so! Did I do something wrong?"
- ironmagma 4y agoThe problem is, very few Git learning resources start off by introducing what refs are, objects, etc. and those that do are usually wrong in some way. There are really not enough learning resources to learn Git this way.