In general, if you write the code, you own the copyright.
You may have written module A, or the file B, or the function C, or the line D. Doesn't matter who else worked on those parts, the parts you write are your own, and the parts you didn't write aren't.
The only difference is that, since this is an open source project, your co-contributors have the same rights as users of the software - they have access to the source, and can freely use, derive, and redistribute the source code to the extent allowed by the license. What they can't do is claim parts they didn't write as their own.
One notable exception is if you explicitly assign the copyright away. This is done so that the project can relicense in the future without having to bother the original authors. A common method of doing so is via Contributor License Agreements. Also, if you are writing code for compensation, check the terms because you're most likely working as a for-hire programmer, where your code is owned by whoever is paying you.
As for who owns the whole, that's a difficult question to answer. Usually this is agreed upon or fought out in court, where one method may be to estimate the number of man-hours each author spent on the project, and multiply by some expected compensation rate. This is no different than how to split assets when a business partnership splits.