Create new branch github12/6/2023 The friction comes in when you're working in a large solution, as this makes branch changes more expensive for IDEs (as they have to do more work to look for changes and update their internal representations etc). Just to be clear, switching branches with git alone is quick and easy. To avoid this, I looked around for ways to make it easier to work on two branches at once Working on multiple git branches at once When the results of the CI change are back, I stash my work-in-progress, switch to the ci-feature branch, make my changes, trigger another build, and switch back to the my-feature branch.Īdding in the IDE branch-switching tax, that gets frustrating quickly. Which means going through the same steps as in scenario 1 above every hour or so. Depending on your CI process, this could lead to a long cycle time, where you have to wait for an hour (for example) to see the results of your changes.ĭue to this cycle time, I normally work on something else in the mean time while I wait to see the fruits of my CI labour. We're constantly trying to optimise and improve our builds, and while we use Nuke to ensure consistency between our local and CI builds, some things have to be tested in CI.Īs anyone who has worked with CI will know, working on a CI branch leads to commits that look like this:Įach of those commits fixes a tiny change, which then needs to be pushed to the server, and wait for a CI build to complete. In my day-job I often work on the CI build process. Unfortunately, it's a scenario I find myself in relatively regularly. Aside from the technical issues we're describing in this post, there's a productivity cost to constant context-switching. This last scenario, working on two separate features at once, sounds like a bad idea. Scenario 3: working on two features at once Unfortunately, as you've already started working on my-feature, this involves the exact same steps as in the previous scenario. Unfortunately, it has a bug, and you need to fix it quickly. In this scenario, you've just finished a feature and pushed it out. This is a conceptually simple set of steps to follow, with the most painful step in my experience being 3-waiting for the IDE to finish doing what it needs to before you can be productive again-and the scenario probably happens rare enough that you don't worry about it too much.Īnecdotally, I've found IDEs get much less "confused" if you use their built-in support for switching git branches, instead of changing them from the command line and waiting for the IDE to "notice" the changes. Once you're done, it's time to switch back, goto 1. From here you can work as normal, commit any changes and push them to the other-feature. For big solutions, it can take a while for the IDE to notice all the changes, reparse the files, and do whatever it needs to do. I find this is often the most painful step, whether I'm using Visual Studio or Rider. Visual Studio, Rider), or you could use the command line git checkout other-feature, or git switch other-feature. Or you could create a "dummy" commit on your branch using git commit -m a "WIP" (which is my preference). You could use git stash -all to save the changes and any new files for all. You offer to checkout their branch to take a look, but that requires a number of steps: The first scenario is when you're working on a feature, coding away on your my-feature branch, when a colleague sends you a message asking to give them a hand with something on their branch other-feature. There are various scenarios I have encountered that require me to switch from one branch to another. Have you ever found yourself having to swap back and forth between different git branches, to work on two different features? Git makes this relatively easy to do, but it can still be a bit annoying and time consuming. Scenarios requiring frequent branch changes Finally I describe how git worktree allows you to check out multiple branches at once, so you can work on two branches simultaneously, without impacting each other. I then present some possible ways to avoid having to change branch. In this post I describe some scenarios in which you need to change git branches frequently and why this can sometimes be annoying.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |