git mv Move or rename a tracked file

Renames or moves a file and stages the change in one step. Git then records it as a rename and keeps the file history connected.

Synopsis

git mv [OPTION]... SOURCE DESTINATION
git mv [OPTION]... SOURCE... DIRECTORY

Common options

Option or formWhat it does
SOURCEThe existing file or folder
DESTINATIONThe new name or location
-fOverwrite the destination if it exists
-n, --dry-runShow what would happen without doing it
-kSkip errors instead of stopping

Examples

Rename a file
git mv readme.txt README.md
Move a file into a folder
git mv logo.png assets/
Preview a rename
git mv -n app.js main.js
Checking rename of 'app.js' to 'main.js'
Renaming app.js to main.js
Check the result
git status
renamed:    app.js -> main.js

Notes

See also

Last reviewed 2026-10-09.