'What is the difference between running "git mv" versus just "mv"

What is actual difference in results when it comes to source control systems, between running a command like:

git mv <src> <dest>  # see: https://git-scm.com/docs/git-mv

versus a "lower" level command like

mv <src> <dest>

is there any difference in the result from a version/source control system's perspective? Or anything/anyone's perspective?

The same goes for other git commands like git rm. I just want to know what difference it makes between running the git functions versus bash functions, or whatever.

git


Solution 1:[1]

Since you have tagged the question with different SCM products and not just git I'm answering this in a more general way.

Each source control system tracks different information about files. In Mercurial, for instance, moves are tracked, so that - along with deletion and addition of the renamed file it also stores information about that being a rename, and which file it has been before.

Also, when deleting files, one usually needs to remove it from SCM as well (sometimes also called forgetting).

So generally speaking the SCM file operation commands do update the file system along with the operations needed for the SCM to track this change.

Solution 2:[2]

git mv stages the move, so you can just git commit afterwards. If you move the file manually, you need to manually stage the move before committing.

Other than that, there is no difference there is just the minor difference Leon's answer covers. The documentation for git mv says:

Move or rename a file, directory or symlink.

...

The index is updated after successful completion, but the change must still be committed.

Solution 3:[3]

Just an extra piece of information, complementing the other answers (this applies solely to giv mv):

If file <dest> exists (no matter tracked or not) then

mv <src> <dest>

will silently overwrite it, whereas

git mv <src> <dest>

refuses to overwrite it, with the following error message:

fatal: destination exists, source=<src>, destination=<dest>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lucero
Solution 2 Community
Solution 3 Leon