# Large files with Git LFS

## When to use it

Git LFS is for binary files that change over time, such as design files, images, or videos. Source code never belongs in LFS: Git already handles text well.

## Set up once per machine

```bash
git lfs install
```

## Track a file type

```bash
git lfs track "*.psd"
```

Commit `.gitattributes` before the files it applies to, so Git knows to use LFS the moment the file is added.

```bash
git add .gitattributes
git commit -m "Track PSD files with LFS"
```

```bash
git add logo.psd
git commit -m "Add logo"
```

```bash
git lfs ls-files
```

```bash
git push
```

## Working with teammates

Every machine that works with this repository needs `git lfs install` run once. Without it, a teammate sees a short pointer text file instead of the real content. Cloning otherwise works the same as any other repository.

```text
version https://git-lfs.github.com/spec/v1
oid sha256:4d7a...
size 102400
```

## Move existing files into LFS

```bash
git lfs migrate import --include="*.mp4" --everything
```

```bash
git push --force-with-lease --all origin
```

This rewrites history, so pause the team before running it, do it on a fresh clone, and have everyone re-clone afterward. It is the one case where force-pushing a shared branch is the right call.

:::note[On Codebahn]
LFS objects count against your objects pool, not git storage: [Plan limits](/docs/limits/#storage). Export archives do not include LFS objects yet: [Export your data](/docs/export/#whats-in-the-archive).
:::

Git basics is licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/): copy it, adapt it, keep the credit.
