I always used a git stash based workflow when I quickly need to switch branches. In newer versions of git (since 2015), the git worktree command lets you che...
I do like worktrees when I need to jump back and forth between branches quite a lot, but for the scenario in the video, i.e. quickly doing a hotfix, I often find them too heavyweight.
You don’t have the build caches anymore when you create a new worktree, so especially when the project has long build times, you’ll be waiting some minutes until you can do your very quick hotfix. Of course, on the plus side, you can leave that to compile and continue working on your non-hotfix branch until it’s ready.
What I particularly don’t like about stashes, which can also happen with worktrees, is that I forget about them. You just get side-tracked for a moment and two weeks later you realize you still had some code somewhere that you never continued working on.
So, especially when I’m mostly working alone on a branch, I like to just create a WIP commit, push it, and then do the hotfix. If anyone needs to pick up from where I left it, they can at least try to complete that commit.
I do like worktrees when I need to jump back and forth between branches quite a lot, but for the scenario in the video, i.e. quickly doing a hotfix, I often find them too heavyweight.
You don’t have the build caches anymore when you create a new worktree, so especially when the project has long build times, you’ll be waiting some minutes until you can do your very quick hotfix. Of course, on the plus side, you can leave that to compile and continue working on your non-hotfix branch until it’s ready.
What I particularly don’t like about stashes, which can also happen with worktrees, is that I forget about them. You just get side-tracked for a moment and two weeks later you realize you still had some code somewhere that you never continued working on.
So, especially when I’m mostly working alone on a branch, I like to just create a WIP commit, push it, and then do the hotfix. If anyone needs to pick up from where I left it, they can at least try to complete that commit.