r/commandline • • 6d ago

Command Line Interface gw: one branch across several repos as git worktrees

I made a small tool for a problem I kept having: one feature, several repos, and the same branch needs a worktree in each one.

gw create -b feat/login -r svc-a,svc-b

makes a directory with both repos checked out on feat/login as worktrees. gw status, gw sync and gw delete operate on all of them. A per-repo .grove.toml sets the base branch (we branch from stage, not main) and a setup command to run after checkout.

CLI details, since that's what this sub cares about: single static Go binary, only needs git. eval "$(gw shell-init)" so gw go can cd. List commands take -o json|jsonl|tsv|name|path so they pipe into fzf and jq. Plugins are gw-<name> binaries on PATH, like git.

Similar tools: gita, mu-repo, myrepos and gr run commands across multiple clones. Grove is different in that it creates worktrees, so each workspace is a separate checkout and you can have several in parallel. agent-of-empires does worktrees but is tied to tmux and a single repo.

https://github.com/nicksenap/grove

2 Upvotes

4 comments sorted by

2

u/kaddkaka 6d ago edited 6d ago

Why do you need a new worktree for a new branch?

I used to make a new worktree for every new branch, but quickly realized that was just extra work. Now I have 4 worktrees and just reuse them.

1

u/No-Razzmatazz7197 6d ago

reusing worktrees changed my life, but i've noticed everyone uses them kinda differently.

while I would never use it myself, I think OP's idea is pretty cool, though I cant imagine it should be more complicated then a little bash function, still a cool idea

1

u/AutoModerator 6d ago

Every new subreddit post is automatically copied into a comment for preservation.

User: nicksenap, Flair: Command Line Interface, Title: gw: one branch across several repos as git worktrees

I made a small tool for a problem I kept having: one feature, several repos, and the same branch needs a worktree in each one.

gw create -b feat/login -r svc-a,svc-b

makes a directory with both repos checked out on feat/login as worktrees. gw status, gw sync and gw delete operate on all of them. A per-repo .grove.toml sets the base branch (we branch from stage, not main) and a setup command to run after checkout.

CLI details, since that's what this sub cares about: single static Go binary, only needs git. eval "$(gw shell-init)" so gw go can cd. List commands take -o json|jsonl|tsv|name|path so they pipe into fzf and jq. Plugins are gw-<name> binaries on PATH, like git.

Similar tools: gita, mu-repo, myrepos and gr run commands across multiple clones. Grove is different in that it creates worktrees, so each workspace is a separate checkout and you can have several in parallel. agent-of-empires does worktrees but is tied to tmux and a single repo.

https://github.com/nicksenap/grove

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.