Is there a nice way to call git mv
on a file from within magit? I know it's possible to run any git command with :, but this won't autocomplete filenames.
git mv moves the file, updating the index to record the replaced file path, as well as updating any affected git submodules. Unlike a manual move, it also detects case-only renames that would not otherwise be detected as a change by git.
To use Magit, type M-x magit-status or C-x M-g j . You can also type C-x p m to open a Magit status buffer in your project root, if you use that functionality in Emacs. The status window is the most common entryway into Magit, but it is not the only one.
As of September 2020, Magit is the most starred Emacs package on GitHub.
I'm not sure offhand if there's a direct way, but...
Given that a mv
is the same thing as a rm
plus an add
, you can just rename the file normally (e.g. in dired), and then stage both of the consequent changes -- a deleted file and a new file.
Git should figure it out.
Edit:
M-x vc-rename-file
?
For reference at least in current verion of magit there is magit-file-rename
which can be invoked by R.
I use dired for this. C-x d
when the file is open, then press !
on the file to run git mv ? newpath
command with the file as the ?
argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With