git mv old-name.txt new-name.txt

Category: Git - Core

git mv old-name.txt new-name.txt

Rename a file and stage the change

Moves or renames a tracked file in one step, staging both the deletion and the addition. Git detects it as a rename in diffs. For moving into a subdirectory, the target directory must already exist.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.