Skip to content

CLI Reference

pygwt

A CLI tool to simplify the git worktree workflow.

Usage:

pygwt [OPTIONS] COMMAND [ARGS]...

Options:

Name Type Description Default
-l, --log choice (trace | debug | info | success | warning | error | critical) The minimum log severity level. info
--version boolean Show the version and exit. False
-h, --help boolean Show this message and exit. False

Subcommands

  • add: Add a new worktree.
  • clone: Clone a repository and set it up for a git worktree based workflow.
  • install: Installers...
  • ls: List all worktrees.
  • rm: Remove a worktree.
  • shell: Spawn a new shell within the selected worktree.
  • switch: Switch to a different worktree.

pygwt add

Add a new worktree.

Adds a new worktree for the given [BRANCH] at the defined destination. If [BRANCH] already exists on the remote, the worktree will track the remote branch.

If [BRANCH] does not exists the new branch will be based on the current HEAD. When [START-POINT] is given the newly created branch is based on [START-POINT] instead.

Usage:

pygwt add [OPTIONS] BRANCH [START_POINT]

Options:

Name Type Description Default
--version boolean Show the version and exit. False
-h, --help boolean Show this message and exit. False
--dest text Destination path for the new worktree directory.
If omitted the the destination is inferred from the repository root + branch name. <function <lambda> at 0x7fe563a6a680>

pygwt clone

Clone a repository and set it up for a git worktree 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.

After cloning the script will switch into the new directory and continues with a few extra configuring steps:

  1. Create an empty bare repository.
  2. Configure remote.origin.fetch: This is important because otherwise we won't get any infos about the branch state with respect to the remote.
  3. Fetch all remotes: Populates the list of remote branches.
  4. Set origin/HEAD, which isn't set by a bare checkout.

All those steps basically create a "normal" clone, with the exception of the missing files.

Usage:

pygwt clone [OPTIONS] URL [DEST]

Options:

Name Type Description Default
--version boolean Show the version and exit. False
-h, --help boolean Show this message and exit. False

pygwt install

Installers...

Usage:

pygwt install [OPTIONS] COMMAND [ARGS]...

Options:

Name Type Description Default
--version boolean Show the version and exit. False
-h, --help boolean Show this message and exit. False

Subcommands

  • alias: Install a Git alias for this application.
  • completions: Install shell completions for the selected shell.
pygwt install alias

Install a Git alias for this application.

Usage:

pygwt install alias [OPTIONS] [NAME]

Options:

Name Type Description Default
--scope choice (local | global | system | worktree) N/A global
--version boolean Show the version and exit. False
-h, --help boolean Show this message and exit. False
pygwt install completions

Install shell completions for the selected shell.

Usage:

pygwt install completions [OPTIONS]

Options:

Name Type Description Default
--version boolean Show the version and exit. False
-h, --help boolean Show this message and exit. False

pygwt ls

List all worktrees.

This is just an alias for for git worktree list.

Usage:

pygwt ls [OPTIONS]

Options:

Name Type Description Default
--version boolean Show the version and exit. False
-h, --help boolean Show this message and exit. False

pygwt rm

Remove a worktree.

This is just an 'alias' for git worktree remove that's suppose to save you some typing.

Usage:

pygwt rm [OPTIONS] NAME [ADDITIONAL_ARGS]...

Options:

Name Type Description Default
--help boolean Show this message and exit. False

pygwt 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:

pygwt shell [OPTIONS] NAME [START_POINT]

Options:

Name Type Description Default
--version boolean Show the version and exit. False
-h, --help boolean Show this message and exit. False
-c, --create boolean Create the worktree if it does not yet exists. False
-d, --delete boolean Delete the checkout after exiting the shell. False

pygwt switch

Switch to a different worktree.

Note

This requires the Shell hooks included in the completion 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 is required to create a new one.

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 directory.

Usage:

pygwt switch [OPTIONS] NAME [START_POINT]

Options:

Name Type Description Default
--version boolean Show the version and exit. False
-h, --help boolean Show this message and exit. False
-c, --create boolean Create the worktree if it does not yet exists. False