https://github.com/egyptianbman/zsh-git-worktrees
A zsh plugin that makes git worktrees much more functional
https://github.com/egyptianbman/zsh-git-worktrees
Last synced: 7 months ago
JSON representation
A zsh plugin that makes git worktrees much more functional
- Host: GitHub
- URL: https://github.com/egyptianbman/zsh-git-worktrees
- Owner: egyptianbman
- License: mit
- Created: 2022-01-30T23:25:53.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-05T20:48:47.000Z (almost 3 years ago)
- Last Synced: 2025-03-30T03:02:43.642Z (8 months ago)
- Language: Shell
- Size: 1.87 MB
- Stars: 14
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-zsh-plugins - git-worktrees - Makes `git` worktrees more functional. Includes tab completions. (Plugins / ZSH on Windows)
- fucking-awesome-zsh-plugins - git-worktrees - Makes `git` worktrees more functional. Includes tab completions. (Plugins / ZSH on Windows)
README
# zsh-git-worktrees
A zsh plugin that makes `git` worktrees much more functional
## Why?
You're in the middle of working on something and someone asks you to change
gears and work on something else. You can commit and switch to another branch
or maybe stash and pop it later. Neither option is really ideal -- and this is
why `git` worktrees exist. The only problem with `git` worktrees is there isn't a
great workflow that allows the power of worktrees to shine through.
## How should I use this?
To get started, source `zsh-git-worktrees.zsh`, then run the following commands
for your repostiory:
```bash
$ mkdir my-neat-project
$ cd my-neat-project
$ git clone https://github.com/neat-org/my-neat-project main
$ cd main
$ gwt main
```
With the above and going forward, you'll have the following directory structure:
```
my-neat-project/
main/
my-neat-project -> my-neat-worktree
my-neat-worktree
my-other-neat-worktree
```
Using `gwt` to switch worktrees, you'll always be in a directory with the same
name as your project -- thanks to the symlink that gwt handles for you. This
helps with things like docker-compose, allowing you to switch between
worktrees, all while tricking compose into thinking you're in one "project".
## Demo

## Auto completion
This plugin automatically loads auto completion. Feel free to hit tab after
`gwt` to get suggestions of available worktrees you can switch to.
## Usage
The following are some example command usage:
```bash
# List current worktrees
$ gwt
# Switch to neat-feature worktree, create it if it doesn't exist.
$ gwt neat-feature
# Rename the current worktree (and branch) to not-as-neat-feature
$ gwt mv not-as-neat-feature
# Remove completed feature and its corresponding branch
$ gwt rm completed-feature
```
Branch `main` is considered special as it holds your base repository. This
means it can't be renamed or replaced.
## Find a bug or want to contribute?
Hopefully you find this as helpful for you as it has been for me. Please feel
free to submit any suggestions or updates you make!