Context. To be able to investigate the chemical history of the entire Milky Way, it is imperative to also study its dust-obscured regions in detail, as this is where most of the mass lies. The Galactic Center is an example of such a region. Due to the intervening dust along the line of sight, near-infrared spectroscopic investigations are necessary to study this region of interest. Aims. The aim of this work is to demonstrate that M giants observed at high spectral resolution in the H- and K-bands (1.5-2.4 mu m) can yield useful abundance ratio trends versus metallicity for 21 elements. These elements can then also be studied for heavily dust-obscured regions of the Galaxy, such as the Galactic Center. The abundance ratio trends will be important for further investigation of the Galactic chemical evolution in these regions. Methods. We observed near-infrared spectra of 50 M giants in the solar neighborhood at high signal-to-noise and at a high spectral resolution with the IGRINS spectrometer on the Gemini South telescope. The full H- and K-bands were recorded simultaneously at R = 45 000. Using a manual spectral synthesis method, we determined the fundamental stellar parameters for these stars and derived the stellar abundances for 21 atomic elements, namely, F, Mg, Si, S, Ca, Na, Al, K, Sc, Ti, V, Cr, Mn, Co, Ni, Cu, Zn, Y, Ce, Nd, and Yb. We systematically studied useful spectral lines of all these elements in the H- and K-bands. Results. We demonstrate that elements can be analyzed from H- and K-band high-resolution spectra, and we show which spectral lines can be used for an abundance analysis, identifying them line by line. We discuss the 21 abundance ratio trends and compare them with those determined from APOGEE and from the optical Giants in the Local Disk (GILD) sample. From high-resolution H- and K-band spectra, the trends of the heavy elements Cu, Zn, Y, Ce, Nd, and Yb can be retrieved. This opens up the nucleosynthetic channels, including the s-process and the r-process in dust-obscured populations. The [Mn/Fe] versus [Fe/H] trend is shown to be more or less flat at low metallicities, implying that existing non-local thermodynamic equilibrium correction is relevant. Conclusions. With high-resolution near-infrared spectra, it is possible to determine reliable abundance ratio trends versus metallicity for 21 elements, including elements formed in several different nucleosynthetic channels. It is also possible to determine the important neutron-capture elements, both s- and r-dominated elements. This opens up the possibility to study the chemical evolution in detail of dust-obscured regions of the Milky Way, such as the Galactic Center. The M giants are useful bright probes for these regions and for future studies of extra-galactic stellar populations. A careful analysis of high-quality spectra is needed to retrieve all of these elements, which are often from weak and blended lines. A spectral resolution of R greater than or similar to 40 000 is a further quality that helps in deriving precise abundances for this range of elements. In comparison to APOGEE, we can readily obtain the abundances for Cu, Ce, Nd, and Yb from the H-band, demonstrating an advantage of analyzing high-resolution spectra.