For example, how would the programmers at AAA game companies go about working on a game? Do they just work on their own part and then everybody puts there code together at the end or something else? I'm just curious to how programmers work together.
This can also apply to a couple of indie devs working on a game together.
They use version control. Popular examples are Subversion, Git and Mercurial.
I suggest you use it for your personal projects too, because it's easy to rewind code, if you know what I mean :)