You usually try to keep the merging to a minimum.
You define an API that borders the code you are working on now with others.
This API-border is very well defined.
The API is a set of functions like: Enemy.move(x,y).
One programer will create the function "move" which moves the enemy. The other programer will create the AI function which tells the enemy when to move.
The only thing they have to decide in advance is that enemy has a move function that takes x & y. This is the API.
The AI programer does not care about how the enemy moves (collison detection etc...).
The "move" programer does not care about why the enemy moves ( the AI ).
And the only thing they decided in advance, is that move takes two parameters: x & y
You can define such API borders in advance any time you want to split the job.
So basically there is a well defined border, and usually a lot of discussion goes in to that. The better you are at the design stage, the less you work you will have merging it later.