The git-smartmv
command-line tool, written by James Cherti, allows moving files and/or directories without having to worry about manually choosing whether to use mv
or git mv
.
- If the file or directory is being moved within the same Git repository,
git-smartmv
usesgit mv
. - If the file or directory is being moved between a Git repository and a non-Git directory or a different Git repository,
git-smartmv
usesmv
.
Installation
sudo pip install git-smartmv
Code language: plaintext (plaintext)
Shell alias
To simplify the usage of this tool, you can add the following line to your ~/.bashrc
:
alias mv="git-smartmv"
Code language: plaintext (plaintext)
Usage
The git-smartmv
command-line tool accepts similar arguments as the mv
command, including the source file or directory to be moved, and the destination file or directory.
Example:
git smartmv file1 file2 directory/
Second example (rename):
git smartmv file1 file2