A complete explanation of Continuous Integration can be found here:
http://www.martinfowler.com/articles/continuousIntegration.html
In brief:
- Only commit code to the code repository that will compile and pass all tests.
- Commit your code frequently
- Use some automated tool to enforce these rules