Effective Git - Worktrees

Worktrees can make switching branches easier

Ingo Richter

2 minute read

You know this situation: you are working on new feature branch of your product. A bunch of files has been changed, nothing has settled yet and lots of uncommitted changes. This is how work in progress looks like. Everything could be alright, but then you are asked to check out that high priority issue that a customer reported. What I did in this situation stash my changes with git stash save and provide a meaningful message for when I have to unstash my changes changes branches and pull from master build the product repro the issue create a new branch for the fix implement the fix and push to the newly created branch let somebody else verify the fix go back to my previous branch git stash pop my work in progress continue working on the feature Introducing Worktrees I was reading git release notes and I stumbled upon something I haven’t heard before in the git context: worktree.

Ingo Richter

6 minute read

Let’s start with a bold statement: We all love to write unit great tests for our code. More or less. – Unknown Programmer Writing unit tests for my code mostly follows this pattern Write a test and make it fail (red) Write the function to fix the test (implement function) Start over with step 1 For one of my projects I was using jest. It’s fast now and it has several features that I highly value.

1 minute read

I was building a Reactjs component, that should toggle between two child components. <Toggle> <Comp1> <Comp2> </Toggle> The render method of Toggle looked like this render() { const content = React.Children.count(this.props.children) > 0 ? this.props.children[0] : this.props.children[1]; return ( ${content} ); } Unfortunately, this didn’t work (index out of bounds), when I passed only one component instead of two. This doesn’t make sense, since the Toggle is supposed to toggle between two components.