Enjoy the detours!

git

The more I use git worktree, the more use cases I find. But what is git worktree? Basically, it takes a copy of your project and creates a new folder with the copy. So that you can work in parallel on the same project, without the need to stash or commit your current changes.

A good use case is, for example, when you are working on feature X and your boss found a bug in your application which needs to be fixed as soon as possible. You tell your boss: “No problem, I'll fix it right away”. You don't need to close your editor, stop the dev server or stash your changes. With git worktree you create a copy of your project into a new branch. Now you can work in parallel on both branches, without juggling with unsaved files.

One new use case, I've found, was while working on a client's project. Usually, we need a VPN to get data into the local dev server. My plan was, to have Storybook running and the main site on localhost, to compare components. The task here was, to rewrite the components from Styled-Components to Linaria CSS. Unfortunately, the VPN had connection issues and I required a different way. So, I've created a new worktree and ran a second Storybook server. Now I was able to compare the components because I had the new files running on one server and the old files on a second. 🥳

To get have an easier life working with git worktree, I've created some git aliases:

[alias]
    ....
    wt = worktree
    wa = worktree add
    wr = worktree remove
    wl = worktree list
    ...

65 of #100DaysToOffload

#log #git #dev

Thoughts? Discuss...