{"id":33385511,"url":"https://github.com/trthomps/git-worktree-zsh-plugin","last_synced_at":"2026-02-06T06:13:46.949Z","repository":{"id":322696656,"uuid":"1090527563","full_name":"trthomps/git-worktree-zsh-plugin","owner":"trthomps","description":"Plugin for Oh My ZSH for working with git work trees","archived":false,"fork":false,"pushed_at":"2025-11-20T18:04:15.000Z","size":3511,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-20T20:08:50.317Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trthomps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-05T19:35:30.000Z","updated_at":"2025-11-20T18:04:19.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/trthomps/git-worktree-zsh-plugin","commit_stats":null,"previous_names":["trthomps/git-worktree-zsh-plugin"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/trthomps/git-worktree-zsh-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trthomps%2Fgit-worktree-zsh-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trthomps%2Fgit-worktree-zsh-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trthomps%2Fgit-worktree-zsh-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trthomps%2Fgit-worktree-zsh-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trthomps","download_url":"https://codeload.github.com/trthomps/git-worktree-zsh-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trthomps%2Fgit-worktree-zsh-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29153369,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T02:39:25.012Z","status":"ssl_error","status_checked_at":"2026-02-06T02:37:22.784Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-11-23T05:00:37.849Z","updated_at":"2026-02-06T06:13:46.941Z","avatar_url":"https://github.com/trthomps.png","language":"Shell","readme":"# Git Worktree Plugin for Oh-My-Zsh\n\nEnhanced git worktree management with bare repository support. This plugin provides convenient commands for working with git worktrees, making it easy to work on multiple branches simultaneously.\n\n## What are Git Worktrees?\n\nGit worktrees allow you to have multiple working directories attached to the same repository. This is particularly useful when you need to work on multiple branches at the same time without constantly switching contexts.\n\n## Workflow Examples\n\n![Demo](https://github.com/trthomps/git-worktree-zsh-plugin/releases/download/assets/demo.gif)\n\n### Starting a new project\n\n```bash\n# Clone repository with worktree setup\ngwtc https://github.com/user/repo.git\n\n# You're now in the main/master worktree\n# Create a new feature branch\ngwtw feature/awesome-feature\n\n# Work on your feature...\n# Switch back to main\ngwtw main\n```\n\n### Working on multiple branches\n\n```bash\n# Create worktree for bug fix\ngwtw bugfix/issue-123 main\n\n# In another terminal, work on a feature\ngwtw feature/new-thing main\n\n# List all your worktrees\ngwtl\n\n# Jump between them with fuzzy finder\ngwtcd\n```\n\n### Cleaning up\n\n```bash\n# Remove finished worktrees\ngwtr feature/completed-feature\n\n# Clean up merged branches and their worktrees\ngwtclean\n\n# Clean up references to manually deleted worktrees\ngwtp\n```\n\n## Benefits of Using Worktrees\n\n1. **No context switching**: Keep your build artifacts, node_modules, and IDE state intact per branch\n2. **Parallel work**: Run tests on one branch while developing on another\n3. **Easy comparison**: Have two branches open side-by-side for easy comparison\n4. **Cleaner workflow**: No need to stash changes when switching branches\n\n\n## Installation\n\n### Oh-My-Zsh\n\n1. Clone this repository into your Oh-My-Zsh custom plugins directory:\n\n```bash\ngit clone https://github.com/trthomps/git-worktree-zsh-plugin.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/git-worktree\n```\n\n2. Add `git-worktree` to your plugins array in `~/.zshrc`:\n\n```bash\nplugins=(... git-worktree)\n```\n\n3. Restart your terminal or run:\n\n```bash\nsource ~/.zshrc\n```\n\n### Optional: Install fzf\n\nFor enhanced interactive selection, install [fzf](https://github.com/junegunn/fzf):\n\n```bash\n# macOS\nbrew install fzf\n\n# Linux\ngit clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf\n~/.fzf/install\n```\n\nMany commands support interactive selection with fzf when no arguments are provided. Without fzf, you'll need to provide arguments manually.\n\n## Keeping the Plugin Updated\n\nTo automatically update this plugin along with Oh-My-Zsh itself, consider using [OhMyZsh-full-autoupdate](https://github.com/Pilaton/OhMyZsh-full-autoupdate). This tool extends Oh-My-Zsh's built-in update mechanism to also update all custom plugins and themes automatically.\n\nInstallation is simple - just add it as another custom plugin, and it will handle updates for all your custom plugins including this one.\n\n## Configuration\n\n### Shared Directories\n\nYou can configure directories to be shared across all worktrees. These directories will be stored in the repository root (next to `.git`) and symlinked into each worktree. This is useful for IDE configurations, build caches, or any files you want to keep synchronized across branches.\n\n**Setup:**\n\nAdd the following to your `~/.zshrc` before loading the plugin:\n\n```bash\n# Example: Share IDE configs and build directories\nGWT_SHARED_DIRS=(.claude .idea .vscode node_modules)\n\nplugins=(... git-worktree)\n```\n\n**How it works:**\n\n1. When you create a worktree (using `gwtc`, `gwta`, or `gwtw`), the plugin automatically:\n   - Creates the shared directories in the repository root if they don't exist\n   - Creates symlinks in the new worktree pointing to the shared directories\n\n2. When you remove a worktree (using `gwtr` or `gwtrm`), the symlinks are cleaned up automatically\n\n**Example structure:**\n\n```\nmy-repo/\n├── .git/              (bare repository)\n├── .claude/           (shared across all worktrees)\n├── .idea/             (shared across all worktrees)\n├── main/              (worktree)\n│   ├── .claude -\u003e ../.claude\n│   └── .idea -\u003e ../.idea\n└── feature-branch/    (worktree)\n    ├── .claude -\u003e ../.claude\n    └── .idea -\u003e ../.idea\n```\n\n**Benefits:**\n\n- IDE settings and configurations stay consistent across branches\n- Build caches (`node_modules`, `.gradle`, etc.) are shared, saving disk space\n- Claude Code and other tool configurations don't need to be reconfigured per branch\n\n## Commands\n\n### `gwtc` - Git Worktree Clone\n\nClone a repository as a bare repository and set up the main worktree. This is the recommended way to start using worktrees with a new repository.\n\n**Usage:**\n```bash\ngwtc \u003crepo-url\u003e [directory-name]\n```\n\n**Examples:**\n```bash\n# Clone and create worktree in directory named after repo\ngwtc https://github.com/user/repo.git\n\n# Clone and create worktree in custom directory\ngwtc https://github.com/user/repo.git my-project\n```\n\n**What it does:**\n- Clones the repository as bare into `directory-name/.git`\n- Automatically detects the default branch (main/master)\n- Creates a worktree for the default branch\n- Changes to the new worktree directory\n\n---\n\n### `gwta` - Git Worktree Add\n\nAdd a new worktree for an existing or new branch.\n\n**Usage:**\n```bash\ngwta \u003cbranch-name\u003e [-b] [base-branch]\n```\n\n**Options:**\n- `-b`: Create a new branch\n\n**Examples:**\n```bash\n# Create worktree for existing branch\ngwta feature/new-feature\n\n# Create new branch and worktree from main\ngwta feature/new-feature -b main\n\n# Create new branch and worktree from current HEAD\ngwta bugfix/issue-123 -b\n```\n\n---\n\n### `gwtw` - Git Worktree Work\n\nQuick switch or create worktree for a branch. This is a smart command that handles multiple scenarios automatically.\n\n**Usage:**\n```bash\ngwtw [branch-name] [base-branch]\n```\n\n**Examples:**\n```bash\n# Switch to existing worktree or create if doesn't exist\ngwtw travis/plat-934-feature\n\n# Create from specific base branch\ngwtw feature/new-thing main\n\n# Interactive branch selection (requires fzf)\ngwtw\n```\n\n**What it does:**\n- If worktree exists: switches to it\n- If branch exists locally: creates worktree and checks it out\n- If branch exists on remote: creates worktree and tracks remote branch\n- If branch doesn't exist: creates new branch from base-branch (defaults to main)\n\n**Note:** If no branch is provided and fzf is installed, an interactive branch selector will appear showing both local and remote branches. You can also type a new branch name in fzf to create it.\n\n---\n\n### `gwtl` - Git Worktree List\n\nList all worktrees with their paths and branches.\n\n**Usage:**\n```bash\ngwtl\n```\n\n**Example output:**\n```\n/path/to/repo/.git         (bare)\n/path/to/repo/main         abc1234 [main]\n/path/to/repo/feature-x    def5678 [feature-x]\n```\n\n---\n\n### `gwtcd` - Git Worktree CD\n\nInteractively select and change directory to a worktree using fzf.\n\n**Usage:**\n```bash\ngwtcd\n```\n\n**Note:** This command requires fzf to be installed and always uses interactive selection.\n\n---\n\n### `gwtr` - Git Worktree Remove\n\nRemove a worktree safely (fails if there are uncommitted changes).\n\n**Usage:**\n```bash\ngwtr [worktree-path]\n```\n\n**Examples:**\n```bash\n# Remove specific worktree\ngwtr feature/old-branch\n\n# Interactive selection (requires fzf)\ngwtr\n```\n\n**Note:** If no path is provided and fzf is installed, an interactive selector will appear.\n\n---\n\n### `gwtrm` - Git Worktree Remove (Force)\n\nForce remove a worktree, even with uncommitted changes.\n\n**Usage:**\n```bash\ngwtrm [worktree-path]\n```\n\n**Examples:**\n```bash\n# Force remove specific worktree\ngwtrm feature/abandoned-branch\n\n# Interactive selection (requires fzf)\ngwtrm\n```\n\n**Note:** If no path is provided and fzf is installed, an interactive selector will appear.\n\n---\n\n### `gwtmv` - Git Worktree Move\n\nMove a worktree to a new location.\n\n**Usage:**\n```bash\ngwtmv \u003csource\u003e \u003cdestination\u003e\n```\n\n**Examples:**\n```bash\ngwtmv feature/old-name feature/new-name\ngwtmv ../old-location ../new-location\n```\n\n---\n\n### `gwtp` - Git Worktree Prune\n\nClean up stale worktree references for directories that have been manually deleted.\n\n**Usage:**\n```bash\ngwtp\n```\n\n---\n\n### `gwtlock` - Git Worktree Lock\n\nLock a worktree to prevent it from being pruned or removed.\n\n**Usage:**\n```bash\ngwtlock [worktree-path] [reason]\n```\n\n**Examples:**\n```bash\n# Lock specific worktree with reason\ngwtlock feature/important \"Work in progress\"\n\n# Interactive selection (requires fzf)\ngwtlock\n```\n\n**Note:** If no path is provided and fzf is installed, an interactive selector will appear.\n\n---\n\n### `gwtunlock` - Git Worktree Unlock\n\nUnlock a previously locked worktree.\n\n**Usage:**\n```bash\ngwtunlock [worktree-path]\n```\n\n**Examples:**\n```bash\n# Unlock specific worktree\ngwtunlock feature/important\n\n# Interactive selection (requires fzf)\ngwtunlock\n```\n\n**Note:** If no path is provided and fzf is installed, an interactive selector will appear.\n\n---\n\n### `gwtclean` - Git Worktree Clean\n\nClean up worktrees and branches that have been merged into the default branch. Automatically detects the default branch (main/master) or you can specify a target branch. **Supports detection of squash merges!**\n\n**Usage:**\n```bash\ngwtclean [target-branch] [-f]\n```\n\n**Options:**\n- `-f` or `--force`: Skip confirmation and automatically clean up\n\n**Examples:**\n```bash\n# Auto-detect default branch and clean up merged branches\ngwtclean\n\n# Clean up branches merged into specific branch\ngwtclean develop\n\n# Force cleanup without confirmation\ngwtclean -f\n\n# Clean branches merged into develop without confirmation\ngwtclean develop -f\n```\n\n**What it does:**\n1. Auto-detects the default branch (main/master) if not specified\n2. Finds branches merged into the target branch using multiple detection methods:\n   - **Traditional merges**: Branches merged with commit history preserved\n   - **Squash merges**: Detects branches mentioned in merge commit messages\n   - **Remote-deleted branches**: Branches whose remote was deleted (likely merged)\n   - **Unpushed branches**: Local-only branches (asks for separate confirmation)\n3. Lists worktrees associated with those merged branches\n4. Removes both the worktrees and deletes the local branches\n5. Handles branches without worktrees separately\n\n**Safety features:**\n- Asks for confirmation before deletion (unless `-f` flag is used)\n- **Separately confirms unpushed local branches** before including them in cleanup\n- Uses safe delete (`git branch -d`) which prevents deletion of unmerged changes\n- Skips the current branch and target branch\n- Properly cleans up shared directory symlinks\n- Shows categorized lists of branches found (traditional, squash-merged, remote-deleted, unpushed)\n\n**Alias:** `gwtcl`\n\n---\n\n## Aliases\n\nThe plugin also provides some convenient aliases:\n\n- `gwt` → `git worktree`\n- `gwtls` → `gwtl` (list worktrees)\n- `gwtrp` → `gwtp` (prune worktrees)\n- `gwtcl` → `gwtclean` (clean merged branches)\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n","funding_links":[],"categories":["Plugins"],"sub_categories":["ZSH on Windows"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrthomps%2Fgit-worktree-zsh-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrthomps%2Fgit-worktree-zsh-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrthomps%2Fgit-worktree-zsh-plugin/lists"}