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.
Using this in CI
CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.
.github/workflows/ci.yml
- uses:actions/checkout@v4with:fetch-depth:0 # history, tags, and git describe all need this- run:|git rev-parse --is-shallow-repository # expect falsegit rev-parse --abbrev-ref HEAD # prints HEAD when detached
Frequently asked questions
git mv: Usage, Options & Common CI Errors?
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 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.