# 4. Branches, Smart Locks, Exclusive Checkout Part of [[UVCS]]. Previous: [[3. Checkin Pending Changes and ignore.conf]]. Next: [[5. Desktop Client and Inviting Teammates]]. **Docs:** [Smart Locks](https://docs.unity.com/en-us/unity-version-control/smart-locks) · Branch create: https://docs.unity.com/en-us/unity-version-control/workflow/create-branch · Gluon branches: https://docs.unity.com/en-us/unity-version-control/gluon/use-branches ## 4.1 Why locks matter more than in Git+LFS Git LFS locks are optional social contracts ([[2. Git LFS]]). UVCS **Smart Locks** (also called **exclusive checkouts**) are a first-class server feature aimed at **non-mergeable** assets — FBX, PSD, WAV, many `.unity` situations where UnityYAMLMerge cannot save you. Goal: only one person updates the latest revision of a locked file at a time. ## 4.2 Checkout vs Lock and checkout When checking out a file ([Smart Locks](https://docs.unity.com/en-us/unity-version-control/smart-locks)): | Action | Behavior | |---|---| | **Checkout** | If lock rules already exist for that context, checkout locks per those rules. | | **Lock and checkout** | If no rule exists, UVCS prompts you to **create a lock rule** for that context. | Locked files show a lock icon. Others attempting checkout get a dialog — they cannot check out, check in, or merge that locked file until the lock releases. Smart Locks track the repository so you can only lock the **latest** revision. If the newest revision lives on another branch, checkout fails with a message instead of letting you edit a stale exclusive copy. ## 4.3 Lock rules | Scope | Notes | |---|---| | **Organization rule** | Applies to repos without their own rules; **one** org rule. | | **Repository-specific rules** | Override org rules; multiple allowed per repo. | Create rules deliberately for extensions / paths that are binary-heavy (`*.fbx`, `*.psd`, cinematic scenes). Do not lock every `.cs` file — text merges exist for a reason. ## 4.4 Retained locks and destination branch Default **destination branch** is `/main` (docs' term). Workflow summary from the Smart Locks page: 1. **Create lock** — checkout from the latest revision (destination branch tip, or a revision with **Retained** status). 2. **Remove lock** — check in on the destination branch, **or** merge to the destination branch after working elsewhere. 3. If you exclusively checked out on a **non-destination** branch and check in there, the lock becomes **Retained**. Merge to destination to clear it. 4. While **Retained**, any user may check out that newest revision (it is no longer held by the original locker in the same way). UVCS warns if a newer version exists on another branch. Admins / lock owners can manually release locks when someone leaves for the weekend with a scene locked. ### Multiple destination branches You can configure multiple destination branches so specialized lines of work lock against their own "source of truth" without constantly colliding. Use this when branches intentionally diverge (live ops vs mainline content). Read the Smart Locks page before teaching it — easy to confuse students. ## 4.5 Technical caveats (do not skip) From Unity's Smart Locks docs: - Smart locks **do not travel across replica** repositories — replicas can leave locks outdated. - A **deleted changeset** can leave an outdated lock. - **Merge-to** does not support locks. - Lock rules do not support the `lockserver` field. ## 4.6 Branches (Plastic-oriented teaching path) Create task branches for features the same way you would in Git ([[4. Conflicts Prefabs and Branching]]): - Prefer Prefab / scene isolation so merges stay small. - Use Branch Explorer in the desktop client for visualization. - Gluon can also create/use branches ([Gluon use branches](https://docs.unity.com/en-us/unity-version-control/gluon/use-branches)) — artists are not stuck on a single line of development. Exact GUI clicks for "Create branch" vary slightly between Editor plugin versions and desktop client builds — prefer the live [create branch](https://docs.unity.com/en-us/unity-version-control/workflow/create-branch) page during demos rather than memorizing button labels from this note. ## 4.7 Pair with Prefab discipline Locks reduce binary pain; they do not fix design mistakes: - One mega `Level_01.unity` still serializes merge hell for anyone unlocking it. - Extract Prefabs, additive scenes ([[SceneManagement in Unity 6]]), ScriptableObject data ([[ScriptableObject Architecture]]) — same architecture advice as the Git series and [[Architecture and Code Patterns]]. ## Next [[5. Desktop Client and Inviting Teammates]] — outside-Editor client and org invites.