CLI Reference¶
git twig¶
'git worktree' as it should be...
Working with git worktree can be a bit finicky at time. git-twig aims to make worktrees a first class citizens, similar to branches.
Using it's shell integration, git-twig makes switching between worktrees as easy as git twig switch...
Usage:
git twig [OPTIONS] COMMAND [ARGS]...
Options:
-l, --log [trace|debug|info|success|warning|error|critical]
The minimum log severity level.
--version Show the version and exit.
-h, --help Show this message and exit.
Subcommands
- add: Create a new worktree.
- clone: Clone a repository and set it up for a
git twig
based workflow. - init: Initialize your shell for git-twig and completions.
- list: List all worktrees.
- remove: Remove a worktree.
- repository: List, switch and register repositories.
- shell: Spawn a new shell within the selected worktree.
- switch: Switch to a different worktree.
git twig add¶
Create a new worktree.
Create a new worktree for the given [BRANCH] at the given [DEST].
If no local branch with the given name exists, a new one will be created.
If one of the remote branches matches the given branch name, the newly created branch will track that remote branch.
If no remote branch exists,
the newly created branch will be forked off of [START POINT].
If [START POINT] is omitted, HEAD
will be used instead.
Usage:
git twig add [OPTIONS] BRANCH [START_POINT]
Options:
--dest PATH Destination path for the new worktree directory. If omitted the
the destination is inferred from the repository root + branch
name.
--version Show the version and exit.
-h, --help Show this message and exit.
git twig clone¶
Clone a repository and set it up for a git twig
based workflow.
The repository will be cloned as a bare repository, which means only the files that usually reside in the .git subdirectory are created.
Those files are created in a .git directory, similar to the regular clone behavior. But since the repository is cloned in bare mode no other files will be created.
Usage:
git twig clone [OPTIONS] URL [DEST]
Options:
--version Show the version and exit.
-h, --help Show this message and exit.
git twig init¶
Initialize your shell for git-twig and completions.
Usage:
git twig init [OPTIONS] [[pwsh|powershell|bash|zsh]]
Options:
--help Show this message and exit.
git twig list¶
List all worktrees.
Usage:
git twig list [OPTIONS]
Options:
--version Show the version and exit.
-h, --help Show this message and exit.
git twig remove¶
Remove a worktree.
This is just a fancy alias for git worktree remove
to complete the 'ecosystem'.
Usage:
git twig remove [OPTIONS] [WORKTREES]...
Options:
-f, --force Force removal even if worktree is dirty or locked
--help Show this message and exit.
git twig repository¶
List, switch and register repositories.
Once registered, git-twig allows you to switch to repositories,
making the usual cd ../../other/repository
obsolete.
Usage:
git twig repository [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Subcommands
- list: List all registred repositories.
- register: Add a repository to the registry of repositories.
- switch: Switch to a different repository.
git twig repository list¶
List all registred repositories.
Usage:
git twig repository list [OPTIONS]
Options:
--help Show this message and exit.
git twig repository register¶
Add a repository to the registry of repositories.
Once registered you can use git twig repository switch
to switch
between registered repositories.
If [PATH] is not given the current working directory is used.
Usage:
git twig repository register [OPTIONS] [PATH]
Options:
--help Show this message and exit.
git twig repository switch¶
Switch to a different repository.
Important
For this to work properly you will need the shell integrations, otherwise this command will just print the directory of the repository to switch to.
Switch to the given [REPOSITORY].
The repository has to be registered first,
using the git twig repository register
command.
If [REPOSITORY] is -
,
you will be returned to the repository
you've previously called this command from.
To switch to a specific branch/worktree set the [WORKTREE] argument.
Usage:
git twig repository switch [OPTIONS] REPOSITORY [WORKTREE]
Options:
--help Show this message and exit.
git twig shell¶
Spawn a new shell within the selected worktree.
Warning
This command spawns a new shell,
which may result in some unexpected side-effects.
Consider using pygwt switch
instead.
Detect the current shell, the command is executed in and spawn a new instance within the directory of the worktree defined by [NAME].
If the branch, defined by [NAME], does not exist and the create flag is set, a new branch will be created. If [START_POINT] is omitted the current HEAD will be used as a start point.
Usage:
git twig shell [OPTIONS] NAME [START_POINT]
Options:
-c, --create Create the worktree if it does not yet exists.
-d, --delete Delete the checkout after exiting the shell.
--version Show the version and exit.
-h, --help Show this message and exit.
git twig switch¶
Switch to a different worktree.
Note
This requires the Shell hooks included in the init scripts. Otherwise it will just print the worktree path
Under the hood worktrees are given an abstract name. With this command [NAME] is the branch name the worktree represents.
This command works similar to git switch
for branches.
If a worktree does not exist the 'create'-flag can be used
to create a new one before switching to it.
The create flag will also create a new branch,
if no branch for the given name could be found.
If [START-POINT] is omitted, the current HEAD
is used.
If [NAME] is -
you will switch to the previous worktree.
Usage:
git twig switch [OPTIONS] NAME [START_POINT]
Options:
-c, --create Create new worktree from a local or remote branch.
--version Show the version and exit.
-h, --help Show this message and exit.