Introducing gwt

After working on it for a bit, and convincing a coworker to use it and provide feedback, I’ve finally made gwt an actual thing. I expect no one will actually use it, but whatever, it’s up for the world to critique.

I spend a lot of time in git for $dayjob. And I’m always working on more than one thing at a time, so I make heavy use of git worktree. If you’re not familiar, git worktree allows you to have multiple branches of the same repo checked out at the same time and you switch between them by simply using cd. Without worktrees, if you try to switch branches in git while having ‘in progress’ changes it will tell you to commit or stash your changes first. That’s super annoying to me and is the main driver for my use of worktrees. The downside to having a ton of worktrees is having to manage them. I hate doing repetitive tasks by hand, so gwt was born to make my life simpler.

With gwt, you can list all your worktrees, list all worktrees in a given repo, switch to a given worktree, create a worktree, and nuke a worktree. Mentally, I wanted to mimic the flow of virtualenvwrapper with its workon command. As such, we set GWT_REPO_HOME to the directory where all your Git repos are checked out, and then we source the gwt script and we’re all set. To ‘work on’ a given branch, you simply gwt mybranch and it will cd into the worktree, automatically pull changes from your origin if there are any, and then pull any changes from your upstream branch if there are any. It’ll also push any locally committed changes to your origin. All of these steps also output exactly what they’re doing so you know what’s going on.

I’m sure there are tools out there that do this already. And I’m sure there are better ways to do the git things that it does. But I and a coworker find it useful, so..