> ## Documentation Index
> Fetch the complete documentation index at: https://docs.diversion.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Import Unreal Engine source

> Bring a UE source build into Diversion with the Diversion UE Source Manager, and keep it up to date from upstream

> [card] Closed preview
>
> The UE Source Manager is in closed preview and is available to selected
> studios only. Commands, flags, and behaviour may change before general
> availability. To request access, contact
> [support@diversion.dev](mailto:support@diversion.dev).

Studios that build Unreal Engine from source need the engine tree under version control alongside the game. Doing that by hand is a long checklist - clone the fork, pull Epic's dependencies, work out which build outputs must be tracked and which must not, and get all of it committed without bloating the repo.

`DiversionUeSourceManager.exe` automates it. One command clones your UE fork, runs Epic's `Setup.bat` to fetch engine dependencies, and commits the whole tree - source, dependencies, and the binaries UE ships pre-committed - into a Diversion repository. A second command refreshes that tree from upstream later.

## The vendor branch

Imports and updates never commit straight to your working branch. They commit to a dedicated **`ue-vendor`** branch, and you merge that branch in when you want to pick up the engine changes.

This keeps engine churn out of your game history until you ask for it, and makes an engine upgrade a normal merge that you can review, delay, or try on a side branch first.

## Prerequisites

* **Windows.** The tool is Windows-only.
* **Diversion installed and signed in.** See the [Quickstart](https://docs.diversion.dev/quickstart.md) if you have not set this up.
* **Git available on `PATH`.**
* **Your own GitHub fork of Unreal Engine**, with your Epic and GitHub accounts linked. The tool clones the URL you hand it - it cannot reach Epic's repository on your behalf. See [UE on GitHub](https://www.unrealengine.com/en-US/ue-on-github).
* **Administrator rights.** Before running `Setup.bat`, the tool adds an outbound Windows Firewall rule for `GitDependencies.exe`. Without elevation this step fails and the import stops.
* **Disk space and time.** A UE source tree plus its dependencies runs well over 100 GB, and a first import can take hours - most of it inside Epic's `Setup.bat`.

> [card] Leave the ignore files alone
>
> Do not edit or delete `.gitignore` or `.dvignore` during the import. Diversion
> reads **both**, and the tool depends on that: UE's own `.gitignore` supplies
> the exclusions, and the `.dvignore` it writes carries a version hint that tells
> Diversion which revision of the ignore rules to apply. Anything the build needs
> that `.gitignore` would have excluded is force-added by the tool. You will edit
> `.gitignore` later, when you add your game project to the tree.

## Getting the tool

Contact [support@diversion.dev](mailto:support@diversion.dev) and you will receive `DiversionUeSourceManager.exe` directly. There is no installer - put the executable wherever you like and run it from a terminal.

To confirm which build you have:

```powershell theme={null}
DiversionUeSourceManager.exe --version
```

## Initial import

> [!NOTE]
>
> Always pass `--single-version`. Hosting several engine versions in one
> repository is not part of this preview - see [Known limitations](#known-limitations).

```powershell theme={null}
DiversionUeSourceManager.exe import --single-version --name MyProject --out-dir C:\projects --url https://github.com/<your-org>/UnrealEngine.git --ref 5.7
```

| Flag | Meaning |
| - | - |
| `--single-version` | Import with UE's original layout - `Engine/`, `Templates/`, `Samples/`, `FeaturePacks/` at the workspace root. Required for the preview. |
| `--name` | Name of the Diversion repository to create. |
| `--out-dir` | Where the workspace is created. The workspace lands at `<out-dir>\<name>\`. Required together with `--name`. |
| `--url` | Clone URL of your UE fork. |
| `--ref` | Branch, tag, or commit to import, exactly as it exists in your fork. Omit to take the fork's default branch. |

> [!NOTE]
>
> Every value in that command is a placeholder - repository name, paths, fork
> URL, and ref. `5.7` in particular is only an example: the ref is handed
> straight to `git`, so it has to be a branch, tag, or commit that actually
> exists in your fork, and release branches and release tags are named
> differently. Check first:
>
> ```powershell theme={null}
> git ls-remote --heads --tags https://github.com/<your-org>/UnrealEngine.git
> ```

### What the import does

**1. Clone your fork**

A shallow clone of `--url` at `--ref` into a scratch directory.

**2. Fetch engine dependencies**

Runs Epic's `Setup.bat`, recording exactly which files it produced. This is the long part.

**3. Create the repository**

Runs `dv init`, then creates and checks out the `ue-vendor` branch.

**4. Copy the engine into the workspace**

`Engine/`, `Templates/`, `Samples/`, `FeaturePacks/`, and the root `Setup` / `GenerateProjectFiles` scripts.

**5. Force-add what the build needs**

Files UE's `.gitignore` excludes but a working tree requires - the binaries UE ships pre-committed, plus everything `Setup.bat` produced - are added explicitly. Regenerable caches (`__pycache__`, `node_modules`, `*.pyc`, and similar) are skipped.

**6. Commit on the vendor branch**

A single commit on `ue-vendor`, its message recording the git ref and the upstream commit it came from.

When it finishes, `<out-dir>\<name>\` is a full UE source tree checked out on `ue-vendor`, and the scratch clone is cleaned up.

## Merge into your working branch

The engine exists only on `ue-vendor` until you merge it:

```powershell theme={null}
dv checkout main
dv merge ue-vendor
```

Do this immediately after the first import. From there you build the engine the usual way - `GenerateProjectFiles.bat`, then your solution.

## After building the engine

Building the engine creates the directories it writes its output into. The build artifacts themselves are ignored and never committed - but Diversion tracks directories as well as files, so those directories turn up in `dv status`, empty, in the thousands.

This is a consequence of building, not of importing. It happens in any workspace where the engine gets built, including a fresh clone - not just the workspace the import created.

The directory structure itself does belong in the repository, so commit it once and everyone who syncs gets a tree the engine can build in.

This is a one-time cost. The directories are listed as **Added** only while they are new to the repository - once committed, every later build produces no status noise at all.

> [card] Do not revert or delete these directories
>
> Reverting them from the Diversion app, or deleting them from disk after the
> build, removes structure the engine build depends on - and breaks the build for
> anyone who syncs after you. Commit them instead.

Once your first full engine build has completed:

**1. Confirm the directories are really empty**

```powershell theme={null}
dv status
```

You should see the directories listed with no - or very few - **file** changes inside them. If real files are showing up, build output is being picked up that should have been ignored; resolve that before committing.

**2. Commit them on your working branch**

```powershell theme={null}
dv commit -a -m "UE build directory structure"
```

This commits the empty directories only - never the build output inside them.

> [card] Build results do not belong in the repository
>
> Compiled engine and editor binaries are never committed here - only the empty
> directory structure is. Getting a compiled editor to the rest of the team is a
> separate job, handled by binary archives: Diversion's native replacement for
> Unreal Game Sync's Precompiled Binaries. See
> [Binary distribution for Unreal Engine](./binary-distribution).

## Updating the engine

> [card] Work in progress
>
> The update flow is still under active development and is not yet dependable.
> The engine version a workspace holds is recorded only in that workspace's local
> metadata (`<workspace>\.diversion\ue_active_version`) - it is not part of
> repository history, so it does not travel with a `dv clone`, and it is gone for
> good if the original import workspace is deleted. In the current preview,
> updates can only be run from the workspace the import created. Talk to us
> before relying on this in a studio workflow.

To pull a newer upstream state into an existing workspace:

```powershell theme={null}
DiversionUeSourceManager.exe update --workspace C:\projects\MyProject --url https://github.com/<your-org>/UnrealEngine.git --ref 5.7
```

The update takes a fresh clone at the ref you ask for, runs `Setup.bat` against it, then compares it to what is already in your workspace and writes only the differences: files that changed upstream are overwritten, files that disappeared are deleted, and identical files are left untouched. The result is committed on `ue-vendor`.

Then merge as before:

```powershell theme={null}
dv checkout main
dv merge ue-vendor
```

When you rebuild the engine afterwards, the same rule applies to any new build directories: commit them, do not revert them.

> [!NOTE]
>
> Do not delete `<workspace>\.diversion\ue_active_version`. It is written during
> the import and read by `update` - without it, the update refuses to run.

## Known limitations

> [card] Preview limitations
>
> These are known and expected in the current preview build.

* **Thousands of empty directories appear in `dv status` after an engine build.** Diversion currently tracks directories as well as files, so every folder the build writes into shows up as **Added** - in any workspace where the engine is built. Commit them rather than reverting them, and it does not recur: see [After building the engine](#after-building-the-engine).
* **Windows only.** The tool depends on `Setup.bat` and other Windows-specific tooling.
* **Administrator rights are required** for the `GitDependencies.exe` firewall rule.
* **A failed run starts over.** There is no resume - the scratch clone and intermediate state are cleaned up when a run ends, whether it succeeded or not. Re-run the same command from the top.
* **One engine version per repository.** A multi-version layout exists in the tool but needs significant manual setup and is not part of this preview. Always pass `--single-version`, and do not use `ue switch`.
* **The update flow is still work in progress.** The record of which engine version a workspace holds lives only in that workspace's local metadata, so updates can be run only from the original import workspace - not from a clone, and not at all if that workspace is gone. See [Updating the engine](#updating-the-engine).

## Related

* [Set up Horde with Diversion](https://docs.diversion.dev/unreal/horde-setup.md) - wiring a prepared UE source repo into a Horde build farm
* [Binary distribution for Unreal Engine](./binary-distribution) - shipping compiled editor builds to the rest of the team
* [Unreal Engine Plugin](https://docs.diversion.dev/unreal/unreal-engine-plugin.md) - source control inside the editor


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.