As we’ve been saying all along, it’s important to be thinking about merging before you even open a new branch. If you’re planning and being thoughtful ahead of time, things are more straightforward when it comes time to merge. Here are some essential tips on merging, including what you should think about, why merge order matters, and what to do to avoid conflicts.
- Try to think about the end result of merging throughout your time working in your branch. Remind yourself what outcome you are intending and what your branch represents.
- Try to stay focused; if you need to update something that you know will impact others, you should instead open a new branch just for that one item.
Whether you have several parallel branches under master, or a parent branch with many child branches, the order in which you merge branches does have an impact. Understanding the impact of merge order minimizes conflicts and reduces duplicated work.
For example, let’s say that you are given a project to design a new feature for your product. First, you will create a parent branch for that feature. This is a large effort, so you want to break this down into smaller pieces. You will create child branches for each separate item which, when put together, will make up your new feature.
You and your teammates will work in those child branches until each small piece of the whole feature is done, and then you will start merging those branches. Here’s where merge order comes in. The first child branch you merge back into the parent will update the parent branch, and now you have to bring those updates into the other child branches before you can move on with them. If the child branch you merged has a lot of changes, you may notice many conflicts that you will need to resolve in your other child branches. If you merged small changes back into the parent branch, there will be smaller changes to go back and fix on the other child branches when you bring in the updates.
With this in mind, you may want to merge smaller items back to the parent branch more frequently so that you can handle conflicts on the other child branches easily. Then the last branch you merge in might have many changes, but you will only need to resolve conflicts for that one branch.
Regardless of how carefully you work, conflicts happen, even in the world of engineering.
- Don’t open or change a file unless you need to because the odds of running into conflicts at merge are higher if you’ve impacted too many files, especially ones others might be working on.
- Try not to delete anything (artboards, pages, files) on the parent branch until child branches are merged.
- When updating your branch from master, only choose your artboard when you know you made a change on that artboard. Embrace it as a moment of reflection on the work done.
- Be discerning when updating from master. You are responsible for the merge, so if you pull in work you didn’t do, you are now accountable for that work.