Lock Commands
Lock files for exclusive editing in team environments. Prevents merge conflicts on binary files that cannot be automatically merged.
Why Lock Binary Files?
Unlike text files, binary files like videos and project files cannot be automatically merged. Locking ensures only one person edits a file at a time, preventing conflicting changes that would require manual resolution.
| Command | Description | Usage |
|---|---|---|
| lock | Lock files for exclusive editing | dits lock [OPTIONS] <PATHSPEC>... |
| unlock | Release file locks | dits unlock [OPTIONS] <PATHSPEC>... |
| locks | List active locks | dits locks [OPTIONS] [PATH] |
dits lock
Lock files for exclusive editing. Other team members will be notified that the file is locked and cannot modify it until you unlock it.
Synopsis
dits lock [OPTIONS] <PATHSPEC>...Options
--reason <TEXT> Provide a reason for locking
--ttl <DURATION> Lock time-to-live (default: 8h)
Examples: 1h, 8h, 24h, 7d
-f, --force Force acquire lock (break existing)
--json Output lock info as JSON
-v, --verbose Show detailed informationExamples
# Lock a single file
$ dits lock footage/scene01.mov
Locked: footage/scene01.mov
Owner: john@example.com
Acquired: 2025-01-15 14:30:00 UTC
Expires: 2025-01-15 22:30:00 UTC
# Lock with a reason (visible to team)
$ dits lock --reason "Color grading in progress" footage/scene01.mov
Locked: footage/scene01.mov
Owner: john@example.com
Reason: Color grading in progress
Expires: 2025-01-15 22:30:00 UTC
# Lock with custom TTL
$ dits lock --ttl 24h footage/scene01.mov
# Lock for extended period
$ dits lock --ttl 7d footage/final-cut.mov
# Lock multiple files
$ dits lock footage/*.mov
Locked 5 files:
footage/scene01.mov
footage/scene02.mov
footage/scene03.mov
footage/interview-a.mov
footage/interview-b.mov
# Lock entire directory
$ dits lock footage/vfx/
# Force lock (override existing lock - use carefully!)
$ dits lock -f footage/scene01.mov
Warning: Breaking lock held by jane@example.com
Locked: footage/scene01.movForce Lock Warning
Using
--force breaks another user's lock. Only use this if the lock holder is unavailable and you have team permission to take over. The original lock holder will be notified.dits unlock
Release locks on files. You can only unlock files you own unless using force mode (admin privilege required).
Synopsis
dits unlock [OPTIONS] <PATHSPEC>...Options
-f, --force Force unlock (admin only)
--all Unlock all your locks
--json Output result as JSONExamples
# Unlock a single file
$ dits unlock footage/scene01.mov
Unlocked: footage/scene01.mov
# Unlock multiple files
$ dits unlock footage/*.mov
Unlocked 5 files:
footage/scene01.mov
footage/scene02.mov
footage/scene03.mov
footage/interview-a.mov
footage/interview-b.mov
# Unlock all your locks
$ dits unlock --all
Unlocked 8 files.
# Force unlock (admin only)
$ dits unlock -f footage/scene01.mov
Warning: Force unlocking file locked by jane@example.com
Unlocked: footage/scene01.movdits locks
List active locks in the repository. See who has locked what files and when locks will expire.
Synopsis
dits locks [OPTIONS] [PATH]Options
--mine Show only your locks
--all Show all locks (including expired)
--expired Show only expired locks
--json Output as JSON
-v, --verbose Show detailed informationExamples
# List all active locks
$ dits locks
Active Locks (5):
File Owner Expires Reason
─────────────────────────────────────────────────────────────────────
footage/scene01.mov john@example.com 6h 30m Color grading
footage/scene02.mov john@example.com 6h 30m Color grading
project.prproj jane@example.com 2h 00m Edit assembly
footage/interview.mov alex@example.com 23h 15m -
audio/music.wav jane@example.com 2h 00m -
# List only your locks
$ dits locks --mine
Your Locks (2):
File Expires Reason
───────────────────────────────────────────────────
footage/scene01.mov 6h 30m Color grading
footage/scene02.mov 6h 30m Color grading
# List locks in specific directory
$ dits locks footage/
Locks in footage/:
footage/scene01.mov john@example.com 6h 30m
footage/scene02.mov john@example.com 6h 30m
footage/interview.mov alex@example.com 23h 15m
# Show expired locks (for cleanup)
$ dits locks --expired
Expired Locks (2):
footage/old-take.mov bob@example.com expired 2d ago
audio/draft.wav jane@example.com expired 4h ago
These can be cleaned with: dits unlock -f <file>
# Verbose output
$ dits locks -v footage/scene01.mov
Lock Details:
File: footage/scene01.mov
Owner: john@example.com
Acquired: 2025-01-15 14:30:00 UTC
Expires: 2025-01-15 22:30:00 UTC (6h 30m remaining)
Reason: Color grading
Lock ID: lock-a1b2c3d4
Branch: mainLock Workflow
# Typical locking workflow:
1. Check if file is locked
$ dits locks footage/scene01.mov
No locks on footage/scene01.mov
2. Lock before editing
$ dits lock --reason "Editing scene 1" footage/scene01.mov
Locked: footage/scene01.mov
3. Edit your file...
# Other team members see:
# $ dits lock footage/scene01.mov
# Error: File locked by john@example.com
# Reason: Editing scene 1
4. Commit your changes
$ dits add footage/scene01.mov
$ dits commit -m "Edit scene 1"
$ dits push
5. Unlock when done
$ dits unlock footage/scene01.mov
Unlocked: footage/scene01.movLock Behavior
What Locks Prevent
- Modifications: Other users cannot modify locked files
- Deletions: Locked files cannot be deleted by others
- Renames: Locked files cannot be renamed by others
- Force pushes: Force push affecting locked files blocked
What Locks Allow
- Reading: Anyone can still read/view locked files
- Cloning: Locks don't prevent cloning the repository
- Pulling: You can still pull changes (including locked files)
Lock Expiration
# Locks automatically expire to prevent abandoned locks
Default TTL: 8 hours
When a lock expires:
- File becomes unlockable by anyone
- Push will fail if you still have uncommitted changes
- Other users can acquire the lock
Extend a lock:
$ dits lock --ttl 8h footage/scene01.mov
Lock extended: expires in 8hBest Practices
- Lock files before editing, unlock immediately after
- Always provide a reason so team knows what you're doing
- Use shorter TTLs for quick edits, longer for complex work
- Check locks before starting work on shared files
Related Commands
- File Commands - Stage and commit files
- Remote Commands - Push and pull changes
- Branch Commands - Branching strategies