I want git to ignore my UserInterfaceState.xcuserstate file in my XCode4 project, but where should I put the .gitignore file?, is it inside the .
You should not put tool-specific files into a project's .gitignore file — unless that tool is required to be used by each developer of the project.
Instead, create your personal global .gitignore file in your home directory and activate it:
git config --global core.excludesfile ~/.gitignore
Now you can put whatever files are generated by your development tools into your .gitignore file.