# Git LFS migrate import errors converting history in CI

> Fix common git lfs migrate import problems in CI - rewriting history to move large files into LFS can fail on missing patterns, dirty trees, or unpushed rewrites.

Source: https://latchkey.dev/learn/command-reference/git-lfs-migrate-import-in-ci  
Updated: 2026-06-30

`git lfs migrate import` rewrites commits so large files become pointers. It fails or does nothing when no include pattern matches, the tree is dirty, or the rewritten history is not force-pushed.

## 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@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### What causes Git LFS migrate import errors converting history in CI?

There are 2 common causes: a dirty working tree blocks the rewrite and the include pattern matches nothing. migrate refuses to run over uncommitted changes to avoid losing work, so a dirty checkout stops it.

### How do I fix Git LFS migrate import errors converting history in CI?

There are 2 fixes depending on which cause you have: run on a clean tree with a correct pattern and preview before rewriting. Work through them in order, since the first is the most common.

### What does Git LFS migrate import errors converting history in CI actually mean?

git lfs migrate import reports "migrate: no files to migrate", refuses on an unclean working tree, or the remote still rejects large files because the rewrite was not pushed.

### How do I stop Git LFS migrate import errors converting history in CI happening again?

Run git lfs migrate info before a destructive import. The prevention section lists 3 changes that keep it from recurring.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
