Skip to main content
Documentation

Branch Commands

Commands for creating, switching, and merging branches in your Dits repository.

CommandDescriptionUsage
branchList, create, or delete branchesdits branch [name]
switchSwitch to a branchdits switch <branch>
checkoutSwitch branches or restore filesdits checkout <branch|file>
mergeMerge branches togetherdits merge <branch>
rebaseReapply commits on top of another basedits rebase <branch>
cherry-pickApply specific commitsdits cherry-pick <commit>
tagCreate and manage tagsdits 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 branches

Examples

# 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 revisions

dits switch

Switch to a different branch, updating the working directory. Only files that differ are hydrated, making branch switching efficient.

Synopsis

dits switch [options] &lt;branch&gt;

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 branch

Examples

# 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 grading

dits merge

Join two or more development histories together. Supports fast-forward, recursive, and squash merge strategies.

Synopsis

dits merge [options] &lt;branch&gt;...

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 message

Examples

# 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 a1b2c3d

Resolving 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 --abort

dits cherry-pick

Apply specific commits from other branches. Useful for selectively bringing in changes without merging entire branches.

Synopsis

dits cherry-pick [options] &lt;commit&gt;...

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 commit

dits 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 --tags

Related Commands