Ground-based high-resolution spectra provide a powerful tool for characterizing exoplanet atmospheres. However, they are greatly hampered by the dominating telluric and stellar lines, which need to be removed prior to any analysis. Such removal techniques (“preparing pipelines”) deform the spectrum; hence, a key point is to account for this process in the forward models used in retrievals. We develop a formal derivation on how to prepare froward models for retrievals, in the case where the telluric and instrumental deformations can be represented as a matrix multiplied element-wise with the data. We also introduce the notion of a “bias pipeline metric,” which can be used to compare the bias potential of preparing pipelines. We use the resulting framework to retrieve simulated observations of 1D and 3D exoplanet atmospheres and to reanalyze high-resolution (
R
≈
80,400
) near-infrared (0.96–1.71 μm) CARMENES transit data of HD 189733 b. We compare these results with those obtained from a cross-correlation function analysis. With our fiducial retrieval, we find a blueshift of the absorption features of
−
5.51
−
0.53
+
0.66
km s−1. In addition, we retrieve a H2O log10(VMR) of
−
2.39
−
0.16
+
0.12
and a temperature of
660
−
11
+
6
K. We are also able to put upper limits for the abundances of CH4, CO, H2S, HCN, and NH3, consistent with a subsolar-metallicity atmosphere enriched in H2O. We retrieve a broadened line shape, consistent with rotation- and wind-induced line broadening. Finally, we find a lower limit for the pressure of an opaque cloud consistent with a clear atmosphere, and we find no evidence for hazes.