Deep pencil beam surveys (<1 deg^2) are of fundamental importance for studying the high-redshift universe. However, inferences about galaxy population properties are in practice limited by cosmic variance. This is the uncertainty in observational estimates of the number density of galaxies arising from the underlying large-scale density fluctuations. This source of uncertainty can be significant, especially for surveys which cover only small areas and for massive high-redshift galaxies. Cosmic variance for a given galaxy population can be determined using predictions from cold dark matter theory and the galaxy bias. In this paper we provide tools for experiment design and interpretation. For a given survey geometry we present the cosmic variance of dark matter as a function of mean redshift z and redshift bin size Dz. Using a halo occupation model to predict galaxy clustering, we derive the galaxy bias as a function of mean redshift for galaxy samples of a given stellar mass range. In the linear regime, the cosmic variance of these galaxy samples is the product of the galaxy bias and the dark matter cosmic variance. We present a simple recipe using a fitting function to compute cosmic variance as a function of the angular dimensions of the field, z, Dz and stellar mass m*. We also provide tabulated values and a software tool. We find that for GOODS at z=2 and with Dz=0.5 the relative cosmic variance of galaxies with m*>10^11 Msun is ~38%, while it is ~27% for GEMS and ~12% for COSMOS. For galaxies of m*~10^10 Msun the relative cosmic variance is ~19% for GOODS, ~13% for GEMS and ~6% for COSMOS. This implies that cosmic variance is a significant source of uncertainty at z=2 for small fields and massive galaxies, while for larger fields and intermediate mass galaxies cosmic variance is less serious.