Skip to main content

hop

CI

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.

hop demo

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 + (like git 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

  • / or j/k - Navigate branches
  • c or Enter - Checkout selected branch (or jump to its worktree, see below)
  • / - Filter branches: type to narrow, / to pick, Enter to checkout, Esc to cancel
  • r - Rebase selected branch onto its base
  • n - Create new branch from selected branch
  • d - Delete selected branch
  • t - Cycle theme (dark/light, then back to the startup theme)
  • h - Show help screen
  • q - 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

git_hop-0.1.0.tar.gz (605.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_hop-0.1.0-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

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

Hashes for git_hop-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3db9ea22a7e21c879f9fb9293ae82862010374e14530b8eebe08be459073b75e
MD5 e6275081349a8d18bad2c242b738e0a2
BLAKE2b-256 3c14daeb02672bd340c07c0843bb51fc5d49b9416fbb63b4b8efac4f53419e48

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_hop-0.1.0.tar.gz:

Publisher: release.yml on LarsMichelsen/hop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for git_hop-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cfa5af6b69f0dfa168f05f146b2837f8bb206cf0445ad0a4a5e9097a82db941
MD5 59758e488810afd7fc80415d4ea79b7e
BLAKE2b-256 c0488f661682c1920a1d861d92344bfeccbe2745fe4f1fc28ca073aafa45c34c

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_hop-0.1.0-py3-none-any.whl:

Publisher: release.yml on LarsMichelsen/hop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.0

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page