+
Skip to content

gko/gwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gwt — A Git Worktree Manager

gwt is a simple command-line tool to help you manage your Git worktrees with ease. It simplifies the process of creating, navigating, and removing worktrees.

You can read more about git worktree here: https://dev.to/konstantin/checking-out-multiple-branches-at-the-same-time-in-git-and-moving-files-between-them-31hk

Features

  • Interactive Navigation: Quickly jump between worktrees using an fzf-powered menu.
  • Quick Add: Create a new worktree from an existing branch and switch to it in one command.
  • Easy Removal: Interactively select and remove worktrees.
  • Direct Access: Jump directly to a worktree for a specific branch.
  • Main Branch Shortcut: Instantly navigate to the worktree of your repository's default branch (main or master).
  • Zsh Completion: Tab completion for commands and branch names in Zsh.

Installation

You will need to install fzf (see this installation instructions) for the interactive features.

With zinit

In your .zshrc:

zinit light gko/gwt

With antigen

In your .zshrc:

antigen bundle gko/gwt

Manual

  1. Clone this repository or download the gwt.sh script.
git clone https://github.com/gko/gwt.git
  1. Source the gwt.sh script in your shell's configuration file (e.g., ~/.bashrc, ~/.zshrc). Add the following line:
# Make sure to use the correct path to where you cloned the repo 
source /path/to/gwt/gwt.sh
  1. Restart your shell or source the configuration file for the changes to take effect:
source ~/.zshrc 

or

source ~/.bashrc

Zsh Completion

For Zsh users, gwt comes with a completion script for commands and branch names.

  1. Make sure the _gwt.zsh_completion file is in a directory that is part of your Zsh fpath. You can check your fpath with echo $fpath. A common location is a custom completions directory like ~/.zsh/completions.
  2. If you don't have a custom completions directory, you can create one and add it to your ~/.zshrc:
mkdir -p ~/.zsh/completions  
# Add this to your .zshrc, before the line that sources oh-my-zsh if you use it  
fpath=($HOME/.zsh/completions $fpath)
  1. Copy or symlink the _gwt.zsh_completion file into that directory.
# Rename it to '_gwt' so Zsh can find it 
cp /path/to/gwt/_gwt.zsh_completion ~/.zsh/completions/_gwt
  1. Restart your shell. You should now have tab completion for gwt commands.

Usage

Usage: gwt [command]
Example:
  gwt               interactively choose a worktree and cd into it
  gwt add <branch>  create a new worktree for <branch> and cd into it
  gwt main          jump to default branch worktree (or repo root)
  gwt master        alias of 'gwt main'
  gwt <branch>      jump to the worktree for <branch>
  gwt remove [-f|--force]
                     interactively remove a worktree (force removal with -f)
Options:
  -h, --help        show this help

License

This project is open source and available under the GPLv3 license.

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载