I often rename files with the
~/gitproj $ mv myfile.foo newname.foo
~/gitproj $ mv newname.foo myfile.foo # Coming back to the old name
~/gitproj $ git mv myfile.foo newname.foo # Moving forth again, but with git
~/gitproj $ git mv --cached myfile.foo newname.foo # a pseudo git command
git add .
Since the effect of
git mv is nothing more or less than the sequence
mv myfile.foo newname.foo git rm --cached myfile.foo git add newname.foo
anyway, you can simply supply the remaining two operations
git rm --cached myfile.foo git add newname.foo
to finish the move. However, that does not save you a single command from your move-back-then-git-move workaround.
Afaik, these two commands cannot be bundled via a git alias: You need to supply two names to two different commands, and that is incompatible with alias substitution. So, if you absolutely want to be able to do this with a single command, you either need to write a shell script or function. With a shell script, you can then alias it in your
~/.gitconfig if you absolutely want to call it as a git command, but I really wouldn't bother if I were you.