Settings

Theme

Show HN: wt a tool to help quickly manage git worktrees

2 points by bnchrch 3 months ago · 0 comments · 2 min read

Reader

Hey all,

I created a small git worktree utility some might find useful when creating worktrees so you can work on a few tasks in your code base in parallel

https://github.com/bnchrch/wt

------

Why did I create this?

------

Essentially raw worktrees are rough

1. You need to decide where in your file system to create them

2. Theres no connection back to the original local repo

3. Theres no way to copy or symlink untracked files (.env, build artifacts etc...)

I looked at existing worktree helpers and could not find anything that both

1. Let me create a branch + worktree and cd to the worktree in one command

2. Prune unused worktrees

3. Set what untracked files I wanted to "sync" and how

So I created my own

------

What does it do?

------

1. Introduces a `.worktree` file you can add to your project that defines:

  1. Where to create worktrees

  2. What files/folders to copy/symlink (e.g. `.env`)

  3. What commands to run when you create a new worktree (`npm install`)
2. Create a branch + worktree + cd to the folder in one command `wt switch <branch-name>`

3. Return to the root repo in one command `wt root`

4. Prune wt related to branches that no longer exist `wt prune --all`

----

Anyway, hope someone finds this useful, happy coding!

No comments yet.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection