9
I was wrong about git stash... - YouTube
(youtube.com)
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Resources
Rules
Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.
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.