Branch Commands
Commands for creating, switching, and merging branches in your Dits repository.
| Command | Description | Usage |
|---|---|---|
| branch | List, create, or delete branches | dits branch [name] |
| switch | Switch to a branch | dits switch <branch> |
| checkout | Switch branches or restore files | dits checkout <branch|file> |
| merge | Merge branches together | dits merge <branch> |
| rebase | Reapply commits on top of another base | dits rebase <branch> |
| cherry-pick | Apply specific commits | dits cherry-pick <commit> |
| tag | Create and manage tags | dits tag [name] |
dits branch
List, create, rename, or delete branches. Branches are lightweight references to commits, making creation and switching instant.
Synopsis
dits branch [--list] [-a] [-r]
dits branch <name> [start-point]
dits branch -d <name>
dits branch -m <old> <new>Options
--list, -l List branches (default)
--all, -a List both local and remote branches
--remotes, -r List remote-tracking branches
--delete, -d Delete a branch
--force, -D Force delete unmerged branch
--move, -m Rename a branch
--copy, -c Copy a branch
--verbose, -v Show commit info with branches
--merged Only show merged branches
--no-merged Only show unmerged branchesExamples
# List local branches
$ dits branch
* main
feature/audio
client-version
# List all branches (including remote)
$ dits branch -a
* main
feature/audio
client-version
remotes/origin/main
remotes/origin/feature/audio
# Create a new branch
$ dits branch feature/color-grade
Created branch 'feature/color-grade' at a1b2c3d
# Create branch from specific commit
$ dits branch hotfix 9f8e7d6
# Rename a branch
$ dits branch -m old-name new-name
Renamed branch 'old-name' to 'new-name'
# Delete a merged branch
$ dits branch -d feature/completed
Deleted branch 'feature/completed'
# Force delete unmerged branch
$ dits branch -D experiment/abandoned
Deleted branch 'experiment/abandoned' (was a1b2c3d)
# Show branches with last commit
$ dits branch -v
* main a1b2c3d Add color grading
feature/audio f5e4d3c Add sound effects
client-version b3c4d5e Client revisionsdits switch
Switch to a different branch, updating the working directory. Only files that differ are hydrated, making branch switching efficient.
Synopsis
dits switch [options] <branch>Options
--create, -c Create and switch to new branch
--force, -f Discard local changes
--detach Detach HEAD at the commit
--merge, -m Merge current changes into new branch
--orphan Create new unparented branchExamples
# Switch to existing branch
$ dits switch feature/audio
Switched to branch 'feature/audio'
Hydrating 3 changed files... done
# Create and switch in one command
$ dits switch -c feature/new-feature
Switched to new branch 'feature/new-feature'
# Switch to remote branch (creates tracking branch)
$ dits switch feature/remote-work
Branch 'feature/remote-work' set up to track 'origin/feature/remote-work'
Switched to branch 'feature/remote-work'
# Force switch (discards changes)
$ dits switch -f main
Warning: discarding local changes
Switched to branch 'main'
# Detached HEAD (specific commit)
$ dits switch --detach a1b2c3d
HEAD is now at a1b2c3d Add color gradingEfficient Switching
dits merge
Join two or more development histories together. Supports fast-forward, recursive, and squash merge strategies.
Synopsis
dits merge [options] <branch>...Options
--no-commit Merge but don't commit
--no-ff Create merge commit even if fast-forward
--ff-only Abort if fast-forward not possible
--squash Squash commits into one
--abort Abort current merge
--continue Continue after resolving conflicts
--message, -m Set merge commit messageExamples
# Basic merge
$ dits merge feature/audio
Updating a1b2c3d..f5e4d3c
Fast-forward
audio/music.wav | new file
1 file changed
# Merge with commit (no fast-forward)
$ dits merge --no-ff feature/color
Merge made by the 'ort' strategy.
footage/scene1.mov | modified
1 file changed
# Squash merge (combine all commits)
$ dits merge --squash feature/many-commits
Squash commit -- not updating HEAD
Automatic merge went well
$ dits commit -m "Merge feature/many-commits"
# Abort a merge
$ dits merge --abort
Merge aborted, returning to a1b2c3dResolving Conflicts
$ dits merge client-version
CONFLICT (content): Merge conflict in footage/scene1.mov
Automatic merge failed; fix conflicts and commit.
# See conflicting files
$ dits status
Unmerged paths:
both modified: footage/scene1.mov
# Choose one version
$ dits checkout --ours footage/scene1.mov # Keep main version
$ dits checkout --theirs footage/scene1.mov # Keep client version
# Or manually resolve, then:
$ dits add footage/scene1.mov
$ dits commit -m "Merge client-version"dits rebase
Reapply commits on top of another base tip. Creates a linear history by replaying your commits on top of the target branch.
Synopsis
dits rebase [options] [upstream [branch]]Options
--onto Rebase onto specific commit
--continue Continue after conflict
--abort Abort rebase
--skip Skip current commit
--interactive Interactive rebase (not supported)Examples
# Rebase current branch onto main
$ dits rebase main
Rebasing (1/3): Add sound effects
Rebasing (2/3): Add music
Rebasing (3/3): Mix audio
Successfully rebased onto main
# Rebase onto specific commit
$ dits rebase --onto main~3 main feature/audio
# Continue after resolving conflicts
$ dits rebase --continue
# Abort rebase
$ dits rebase --abortRebase Warning
dits cherry-pick
Apply specific commits from other branches. Useful for selectively bringing in changes without merging entire branches.
Synopsis
dits cherry-pick [options] <commit>...Examples
# Apply a single commit
$ dits cherry-pick a1b2c3d
[main f6g7h8i] Add sound effects
# Apply multiple commits
$ dits cherry-pick a1b2c3d b2c3d4e c3d4e5f
# Cherry-pick without committing
$ dits cherry-pick --no-commit a1b2c3d
Changes applied, ready to commitdits tag
Create, list, or delete tags. Tags mark specific points in history, commonly used for releases or important milestones.
Synopsis
dits tag [--list]
dits tag <name> [commit]
dits tag -d <name>Examples
# List tags
$ dits tag
v1.0
v1.1
v2.0-beta
# Create lightweight tag
$ dits tag v1.2
# Create annotated tag
$ dits tag -a v1.2 -m "Release version 1.2"
# Tag specific commit
$ dits tag v1.0-final a1b2c3d
# Delete tag
$ dits tag -d old-tag
# Push tags to remote
$ dits push --tagsRelated Commands
- Branching & Merging - Branch concepts
- Remote Commands - Push and pull branches
- History Commands - View branch history