logoalt Hacker News

tim-projectsyesterday at 9:00 PM3 repliesview on HN

I haven't been able to use worktrees because when there are major conflicts I find the ai can't handle it. Often it ends up dropping a lot of code.

How do you manage that? How do you successfully navigate complex merges using ai?


Replies

dagssyesterday at 9:11 PM

Claude can easily do the merges I need (or myself manually for that matter). I guess all codebases and usecases are very different here and hard to give general advice.

But I do have many years of experience working in a larger team and it's the same problem there (just that people want to merge after some days of working). I'm not sure if AI changes the picture much vs working in a team.

Either way one has to plan ahead a bit and select tasks that are not going to trample on each other. I can typically imagine roughly what the code generated is going to be (at least what files will likely be involved in what way) and when selecting tasks to work on I take into account if it's going to likely cause conflicts.

In my experience if different branches work on different things, Claude have no issue doing "trivial" merges where you just ended up changing different aspects of the same lines. Of course, if two branches rewrite the same pieces of code there's a problem -- so don't do that..

doolsyesterday at 9:07 PM

I always rebase the worktree back to the source branch before merging, and resolve conflicts on the branch. I have a resolve conflicts skill and just say:

echo “resolve conflicts” | runpi

Where runpi is my pi -p wrapper. I’ve never had a regression from it, but it gives me a report at the end so I can double check the decisions if I need to.

The skill is basically don’t use automatic resolvers, err on the side of including both sides, refer to recent commits, missions and runfiles for context and in your report to me use real branch names not HEAD and incoming because I can never remember what those refer to.

nomelyesterday at 10:36 PM

As conceptually required, serialized work that works on the same lines of code, or fix conflicts.