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 form | What it does |
|---|---|
SOURCE | The existing file or folder |
DESTINATION | The new name or location |
-f | Overwrite the destination if it exists |
-n, --dry-run | Show what would happen without doing it |
-k | Skip errors instead of stopping |
Examples
git mv readme.txt README.md
git mv logo.png assets/
git mv -n app.js main.js
Checking rename of 'app.js' to 'main.js'
Renaming app.js to main.js
git status
renamed: app.js -> main.js
Notes
- It is the same as mv followed by git add on both paths. Doing it by hand gives the same result.
- Git detects renames from content, so a rename plus a big edit in one commit can look like a delete and an add. Rename first, commit, then edit.
- On case-insensitive systems, git mv is the safe way to change only the case of a name.
See also
Last reviewed 2026-10-09.