2 ms·
I think a lot of the pain in git boils down to code structure and how merge conflicts conflate any bad decisions made there. If your codebase is well-structured
by bob1029 6y ago
I think a lot of the pain in git boils down to code structure and how merge conflicts conflate any bad decisions made there. If your codebase is well-structured, I.e. each logical unit of business functionality is in an independent source file or method, then disparate work branches should not create much trouble, even if they are wildly out of sync relative to current master. Git will transparently create merge commits if you do not explicitly rebase (and there are no conflicts).
Many times you have to explicitly sit down and spend a few days/weeks determining if you need higher-order abstractions which enable granularity in the code. For instance, we've developed abstractions such as View/Workflow/Context/Step which contain logical groupings/subsets of business logic and which are easily reasoned with in isolation (i.e. allowing many concurrent work branches). These were explicitly developed so that the software engineering process could function effectively.
Another potential pain point would be trying to do too much work on 1 branch or letting it become perpetual. Ideally, your work branches are a daily/weekly lifecycle before being merged back down to master. You should probably not try to maintain more than 1 permanent master branch unless you can confidently justify reasons for having another.
One good thing to practice would be to rebase any outstanding work branches against master after merging any work. (git checkout master && git pull && git checkout <work branch> && git rebase master). The more frequently you do this, the less likely you will wind up with a nasty merge conflict situation. This also allows you to re-test your work in terms of what would actually happen after a merge to master prior to making the merge. This makes it possible to develop effective check build safeguards in products like GitHub Actions.