TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: What is your approach to dealing with merge conflicts day in / day out?

1 pointsby jossclimbalmost 2 years ago
I am working on a project with quite few others (OSS) and constantly hitting merge conflicts, which I then turn into a dumpster fire. Sometimes things go well, other times I just close the PR. Make a fresh branch and start again, as git and GitHub have fallen out.<p>My current approach is:<p>1. Change to main<p>2. `git pull` latest changes<p>3. Change to my feature branch<p>4. git merge origin&#x2F;main<p>5. Get CONFLICTS<p>6. Fix CONFLICTS<p>7. git add -A<p>8. git commit -m &quot;Rebase from main&quot;<p>9. Fingers crossed, git push origin myfeature<p>I have also tried `git rebase origin&#x2F;main` at #4, but this often pulls everyone elses commits into my change, which gets me complaints during review.<p>At this point it will either go well, or blow up. Sometimes GitHub will claim there is still a merge conflict, even though my local file and the remove file in main are identical. Other times I have new commits locally, I push them upstream and git tells me<p>Is there any idiot proof approach I can take here. I am guessing this is more the tradesmen at fault, more than the tools. So willing to look a fool here, but this is a bit of a PIA right now.

1 comment

xnorswapalmost 2 years ago
If merge conflicts are that common, either you&#x27;re all tripping over each other trying to do things in different ways, or they are &quot;artificial&quot; conflicts caused by people rebasing public shared &#x2F; branches.<p>Merge conflicts should be occasional, not an everyday occurrence.<p>Atlassian&#x27;s golden rule: Never rebase a public branch.<p>Try to understand where conflicts are coming from. Are people committing different linting&#x2F;whitespace&#x2F;line-endings.<p>If so, then get automated tooling on the repo which enforces a linting and style guide to prevent re-format conflicts.<p>If they&#x27;re from genuine refactors, try to understand why people are refactoring so much in a way that is causing conflicts.