Skip to content
TopicTracker
From HackerNewsView original
TranslationTranslation

Show HN: NT – fly around Git worktrees from your shell

nt (navigate tree) is a Zsh utility that simplifies managing Git worktrees. A single command like "nt fix-login" creates or switches to a worktree for a given branch, automatically fast-forwarding to origin while preserving un-pushed commits. It includes commands for navigating, removing, and selecting worktrees with fzf and tab completion.

Background

- **Git worktrees** let you check out multiple branches of the same repository simultaneously in separate directories, so you can work on a bugfix, a feature, and a review without stashing or cloning the repo again. But they are clunky: you have to manually create/delete them, remember their paths, and switch directories. - **nt (navigate tree)** is a small zsh shell script that wraps git worktrees into a single command: `nt fix-login` creates (or jumps to) a worktree for that branch and drops you into the right folder. `nt rm` removes it, `nt home` goes back to the main repo. - It also auto-fetches from the remote (`origin`), so you're working on the latest version of the branch — unless you have unpushed local commits, which it preserves. - The tool is aimed at developers who juggle multiple branches and find worktree bookkeeping a distraction. It's about 240 lines of shell code, MIT-licensed, and meant for Zsh users (common on macOS).