This article analyzes how the anticipation of peer-punishment affects cooperativeness in the provision of public goods under social identity. For this purpose we conduct one-shot public good games with induced social identity and implement in-group, out-group and random matching protocols. Our measure of cooperativeness is subjects' conditional contribution elicited via the strategy method, which allows for observing behavior contingent on every possible level of group members' cooperation. We demonstrate, firstly, that the social environment is a determinant of how the threat of peer-punishment influences cooperation. The strongest increase is clearly evident when subjects interact with members of different identities, which is especially the case for individuals who were initially categorized as freeriders. Secondly, anticipation of peer-punishment clearly eliminates the typically existing ingroup bias without punishment and renders out-group members to be as cooperative as ingroups members. Lastly, the results indicate that the institutions of peer-punishment and social identity may be complemented in order to raise subjects' cooperativeness.