I found this post Sharing IntelliJ IDEA Project Files in Version Control via the twitter-sphere.
They talk of all the usual stuff like ignore the iws file, but they introduced a neat trick for project variables which I didn’t know about.
If you edit your ipr or iml files, you can replace values with the text $whatever_project_var_you_please$ and then when someone else checks out the project and doesn’t have the vars set, a Configure Path Variables dialog pops up and asks you to set them.
I’ll be keen to give this a try at work as we recently switched from .ipr to the .idea dir format to avoid some conflicts we’ve been having, but I suspect that doing so is not the silver bullet alone, the above tip may help – by replacing what varies and let the devs set variables locally.
The next questions to ask is how this gets handled by Teamcity (I presume there are some system properties that you set in the team city project) and how in Idea, you can change these project variables. But otherwise its a very neat tip.
Edit: To change these vars, I believe you can simply go into the File->Settings->Path Variables … Simple