Look into Revision Control systems. It's a pretty wide topic, so I can't say everything in one post, but they're basically a way to share code by keeping a repository that others can check into / out of. The big free ones these days are subversion, git, and mercurial, and which you use depends largely on what host you want (unless you roll your own hosting, in which case you can pick). Github uses git (obviously), but afaik doesn't allow private repositories, so this is only an option if you want your project to be open sourced. There's also bitbucket, which supports both git and mercurial. They allow unlimited private repos, but place a limit on team sizes for free ones. There's a bajillion other sites out there as well, with varying degrees of permissions and requirements.
If you're working on different files, it's just a matter of pushing (or checking in, depending on what system you use) to the repo when you're done, and pulling out of the repo when you're ready to work on something so that your working copy will be pristine. When there are conflicts (such as working on the same file), there are builtin tools that try to combine the changes without human intervention if possible.