GitHub - Syntaf/hop: Jump to the git worktree holding a branch · GitHub
/" data-turbo-transient="true" />
Skip to content
Type / to search
Sign in<br>Sign upAppearance settings
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
Syntaf
hop
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star
main
BranchesTags
Go to file
CodeOpen more actions menu
Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit
History<br>3 Commits<br>3 Commits
bin
bin
shell
shell
.gitignore
.gitignore
README.md
README.md
install.sh
install.sh
View all files
Repository files navigation
hop
Jump to the git worktree holding a branch.
If you keep a lot of worktrees, finding the one holding a given branch means<br>running git worktree list in repo after repo — and the worktree's directory<br>name usually isn't the branch name. hop searches every repo you have at once<br>and cds you there.
$ hop login-fix<br>repo webapp<br>branch feature/login-fix<br>status in sync with origin, no tracked changes<br>path ~/Code/webapp/.claude/worktrees/pr-4821-review
Install
curl -fsSL https://raw.githubusercontent.com/Syntaf/hop/main/install.sh | bash
If you would rather not pipe a script into a shell — reasonable — download it,<br>read it, then run it. The && matters: without it a failed download still gets<br>executed.
curl -fsSL https://raw.githubusercontent.com/Syntaf/hop/main/install.sh -o hop-install.sh \<br>&& less hop-install.sh && bash hop-install.sh && rm hop-install.sh
Or from a checkout, which skips the download entirely:
git clone https://github.com/Syntaf/hop.git && cd hop && ./install.sh
The installer asks where you keep your repos, guessing from the conventional<br>directories (~/Code, ~/src, ~/Projects, …) by counting git repos in each:
hop-install: which directory holds your git repos? [~/Projects]
Press Enter to take the guess, or type a path (~ works). It writes that as<br>HOP_CODE_ROOT in your .zshrc. To skip the question — for a scripted or<br>unattended install — set it yourself:
curl -fsSL https://raw.githubusercontent.com/Syntaf/hop/main/install.sh | HOP_CODE_ROOT=~/src bash
With no terminal to prompt on, it uses the guess and tells you how to change it,<br>rather than hanging.
Then open a new shell. The installer puts hop-resolve in ~/.local/bin,<br>hop.zsh in ~/.config/hop, and adds a short block to your .zshrc. It is<br>idempotent — re-run it to upgrade, and it will leave an existing config alone<br>rather than re-asking. To uninstall, delete those two files and that block.
Requires zsh, bash 3.2+ (macOS stock is fine), git, and curl.
Pin a version with HOP_REF, and change where things land with HOP_BIN_DIR /<br>HOP_CONF_DIR:
curl -fsSL https://raw.githubusercontent.com/Syntaf/hop/main/install.sh | HOP_REF=v0.1.0 bash
HOP_REF is what pins the version — fetching install.sh from a tag URL alone<br>does not, since the script then fetches its payload from main. Note also that<br>raw.githubusercontent.com caches for a few minutes, so an install run<br>immediately after a push may get the previous commit.
Usage
cd into the matching worktree (prompts when ambiguous)<br>hop list every worktree it can find<br>hop -l list matches without cd'ing<br>hop -p print the path only: code "$(hop -p my-branch)"<br>hop -h full help">hop cd into the matching worktree (prompts when ambiguous)<br>hop list every worktree it can find<br>hop -l list matches without cd'ing<br>hop -p print the path only: code "$(hop -p my-branch)"<br>hop -h full help
You never name a repo — every repo under ~/Code is searched at once. A repo<br>name is just an optional extra word to narrow things down: hop webapp login-fix. Tab completion covers branch and worktree names.
Matching runs in tiers, best tier wins, and ties prompt you to pick rather than<br>guessing:
tier<br>matches<br>example
exact branch<br>claude/fix-thing
exact branch leaf<br>fix-thing
exact worktree directory<br>pr-4821-review
branch substring<br>fix-th
worktree directory substring<br>4821
every word appears somewhere<br>webapp alice session
Worktrees in the repo you're standing in sort first.
Creating worktrees
When no worktree holds the branch, hop looks for the branch itself — local<br>branches with no worktree, plus any remote-tracking ref already fetched — and<br>offers to make one:
$ hop session-timeout<br>hop: no worktree holds alice/4821-session-timeout — it is a local branch in webapp.<br>create a worktree at ~/Code/webapp/.claude/worktrees/alice+4821-session-timeout? [y/N]
Remote-only branches are fetched first and the new local branch is set to track<br>them. Nothing is created without a y/N. If the branch is so new that no<br>remote-tracking ref exists, hop offers to fetch the repo you're standing in,<br>or you can name it: hop .
New worktrees land in /.claude/worktrees/, with / in the<br>branch name written as +....