LinuxCommandLibrary

cotton

Git worktree management wrapper

TLDR

Initialize cotton in a repository

$ cotton init
copy
Create a new worktree
$ cotton new [branch-name]
copy
List all worktrees
$ cotton list
copy
Switch to a worktree
$ cotton switch [branch-name]
copy
Remove a worktree
$ cotton remove [branch-name]
copy
Show current worktree status
$ cotton status
copy

SYNOPSIS

cotton command [options] [arguments]

DESCRIPTION

cotton is a Git worktree management tool that simplifies working with multiple branches simultaneously. It wraps Git's worktree functionality with a more intuitive interface for creating, switching, and managing worktrees.
Git worktrees allow checking out multiple branches at once in separate directories, useful for comparing implementations, reviewing pull requests while continuing development, or running tests on different versions. Cotton manages these worktrees with consistent naming and organization.
The tool maintains a directory structure for worktrees and provides quick switching between them, making multi-branch development workflows more efficient than constantly stashing and switching branches.

PARAMETERS

init

Initialize cotton configuration in the repository.
new BRANCH
Create a new worktree for the specified branch.
list
List all managed worktrees.
switch BRANCH
Switch to the specified worktree.
remove BRANCH
Remove a worktree.
status
Show the status of all worktrees.
prune
Remove stale worktree references.
--help
Display help information.
--version
Display version information.

CAVEATS

Requires Git with worktree support (Git 2.5+). Each worktree consumes disk space for the working directory. Changes must be committed or stashed before removing worktrees to avoid losing work.

HISTORY

cotton emerged from the developer community's need for simpler Git worktree management. While Git worktrees were introduced in Git 2.5 in 2015, tools like cotton provide more user-friendly interfaces for common worktree operations.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community