Skip to content
Latchkey

git mv: Usage, Options & Common CI Errors

git mv renames or moves a file and stages the move in a single step.

git mv is shorthand for mv + git add + git rm of the old path, keeping rename detection clean.

What it does

git mv renames or relocates a tracked file (or directory) on disk and stages both the removal of the old path and the addition of the new one.

Common usage

Terminal
git mv old.txt new.txt
git mv src/ lib/
git mv -f a.txt b.txt        # overwrite an existing b.txt

Options

FlagWhat it does
-f / --forceOverwrite an existing destination
-kSkip moves that would error, instead of failing
-n / --dry-runShow what would happen
-v / --verboseReport names as they are moved

Common errors in CI

fatal: destination exists, source=… (use -f to overwrite). fatal: not under version control, source=… means the file is not tracked - git mv only works on tracked paths; add it first or use a plain mv plus git add.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →