hop
Helper for quick git branch hopping.
When you live in short-lived feature branches, switching between them with git checkout means
remembering names and typing them out. hop shows the branches you've touched most recently at the
top, so the one you want is almost always a keystroke away.
Recorded from a reproducible synthetic repo — see demo/PLAYBOOK.md.
Features
- Interactive text-based UI for browsing git branches
- List branches ordered by last commit date
- Type-to-filter:
/narrows the list as you type - Show branch info: date, name, and last commit message
- Details line for the selected branch: commits ahead/behind its base branch
and its upstream (e.g.
base main: +2 -5 | upstream origin/x: +1 -0) - Quick actions: checkout, rebase, delete, or create branches
- Shows upstream branch and merge status
- Worktree aware: branches checked out in another worktree are marked
+(likegit branch), checkout/delete of them is refused with a clear message, and rebase runs inside the worktree that holds them - Vim-style navigation (arrow keys or j/k)
Installation
Requires Python 3.12 or newer. Installation via uv recommended (isolated, added to PATH):
uv tool install git-hop
Or install the latest development state straight from the repository:
uv tool install git+https://github.com/LarsMichelsen/hop.git
Updating
uv tool upgrade git-hop
Usage
The package installs the command as both hop and a git hop subcommand:
hop # launch the interactive branch browser
git hop # the same, as a git subcommand
hop --help # show usage and exit
hop --version # print the version and exit
Note: the worktree-jumping shell wrapper below wraps hop; git hop runs
without it (everything works, jumping to another worktree just tells you the
path instead of changing into it). And as with any external git subcommand,
git hop --help asks git for a man page — use hop --help instead.
Controls
↑/↓orj/k- Navigate branchescorEnter- Checkout selected branch (or jump to its worktree, see below)/- Filter branches: type to narrow,↑/↓to pick,Enterto checkout,Escto cancelr- Rebase selected branch onto its basen- Create new branch from selected branchd- Delete selected brancht- Cycle theme (dark/light, then back to the startup theme)h- Show help screenq- Quit
Shell integration: jump between worktrees
Branches checked out in another worktree are marked +. Pressing c on one
jumps to that worktree — but hop runs as a child process and cannot change
your shell's working directory by itself. Add this wrapper to your
~/.bashrc / ~/.zshrc:
hop() {
local tmp target
tmp="$(mktemp)"
command hop --cd-file "$tmp" "$@"
target="$(cat "$tmp")"
rm -f "$tmp"
if [ -n "$target" ] && [ "$target" != "$PWD" ]; then
cd "$target" || return
fi
}
Or for fish (~/.config/fish/config.fish):
function hop
set -l tmp (mktemp)
command hop --cd-file $tmp $argv
set -l target (cat $tmp)
rm -f $tmp
if test -n "$target" -a "$target" != "$PWD"
cd $target
end
end
Without the wrapper everything else still works; pressing c on a + branch
then shows where the branch lives instead of jumping.
Configuration
hop reads an optional TOML file at ~/.config/hop/config.toml. Everything in
it is optional. An absent file, section, or key falls back to the defaults
shown below. A file that exists but cannot be parsed (or contains invalid
values) is an error: hop refuses to start until it is fixed — or rewritten
with hop init-config --force. Create a documented starting point with:
hop init-config # write ~/.config/hop/config.toml
hop init-config --force # overwrite an existing file
[ui]
# Color theme. "auto" (default) honours $HOP_THEME, otherwise adapts to the
# terminal's ANSI palette. Also accepts "light", "dark", or any built-in
# Textual theme, e.g. "nord", "gruvbox", "dracula", "monokai", "tokyo-night",
# "catppuccin-mocha", "catppuccin-latte", "solarized-light", "flexoki".
theme = "auto"
[defaults]
# Prefix pre-filled in the "new branch" dialog when the source branch has no
# entry in [branch_prefixes].
branch_prefix = ""
[branch_prefixes]
# Per-source-branch prefixes: creating a branch from one of these pre-fills the
# input with the mapped prefix. Quote names containing dots or slashes —
# unquoted, TOML splits keys like 2.5.0 at the dots.
main = "feature/"
develop = "feat/"
# "release/v1.0" = "bugfix/"
# "2.5.0" = "bugfix/"
| Setting | Purpose |
|---|---|
[ui] theme |
Color theme; "auto" adapts to the terminal. Cycle themes at runtime with t (always returns to the configured theme). |
[defaults] branch_prefix |
Default prefix for new branch names. |
[branch_prefixes] |
Prefix overrides keyed by the source branch you create from. |
Development
# Install dependencies
uv sync
# Run the tool
uv run hop
See docs/DEVELOPMENT.md for development workflow and pre-commit checks.
License
Apache License 2.0 © Lars Michelsen
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git_hop-0.1.0.tar.gz.
File metadata
- Download URL: git_hop-0.1.0.tar.gz
- Upload date:
- Size: 605.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3db9ea22a7e21c879f9fb9293ae82862010374e14530b8eebe08be459073b75e
|
|
| MD5 |
e6275081349a8d18bad2c242b738e0a2
|
|
| BLAKE2b-256 |
3c14daeb02672bd340c07c0843bb51fc5d49b9416fbb63b4b8efac4f53419e48
|
Provenance
The following attestation bundles were made for git_hop-0.1.0.tar.gz:
Publisher:
release.yml on LarsMichelsen/hop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_hop-0.1.0.tar.gz -
Subject digest:
3db9ea22a7e21c879f9fb9293ae82862010374e14530b8eebe08be459073b75e - Sigstore transparency entry: 2396309251
- Sigstore integration time:
-
Permalink:
LarsMichelsen/hop@4aabd7921de11b36a1293444b33deb34a8e37e37 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/LarsMichelsen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4aabd7921de11b36a1293444b33deb34a8e37e37 -
Trigger Event:
push
-
Statement type:
File details
Details for the file git_hop-0.1.0-py3-none-any.whl.
File metadata
- Download URL: git_hop-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cfa5af6b69f0dfa168f05f146b2837f8bb206cf0445ad0a4a5e9097a82db941
|
|
| MD5 |
59758e488810afd7fc80415d4ea79b7e
|
|
| BLAKE2b-256 |
c0488f661682c1920a1d861d92344bfeccbe2745fe4f1fc28ca073aafa45c34c
|
Provenance
The following attestation bundles were made for git_hop-0.1.0-py3-none-any.whl:
Publisher:
release.yml on LarsMichelsen/hop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_hop-0.1.0-py3-none-any.whl -
Subject digest:
0cfa5af6b69f0dfa168f05f146b2837f8bb206cf0445ad0a4a5e9097a82db941 - Sigstore transparency entry: 2396309783
- Sigstore integration time:
-
Permalink:
LarsMichelsen/hop@4aabd7921de11b36a1293444b33deb34a8e37e37 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/LarsMichelsen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4aabd7921de11b36a1293444b33deb34a8e37e37 -
Trigger Event:
push
-
Statement type: