As seen in an HR-diagram, a certain stellar classification can correspond to more than one group/sequence of stars (G5 could for instance be either a giant, main sequence star or a white dwarf and so on). I have read in my textbook that even though these groups might have the same absorption spectrum, they can be distinguished by the thickness of their absorption-lines. For instance, giants have narrow lines and dwarfs broad ones. What is the physical explanation of this?
There are many mechanisms which can contribute to broadening spectral lines. Usually, one way or another, the atoms have a broad range of random velocities which cause doppler shifts of varying amounts, broadening the line. One the more fundamental cases is simple 'thermal broadening', where the velocity is from thermal motion. The hotter the gas is, the higher the velocity, the broader the line.
You might think, then, that stars of the same spectral class (with similar temperatures) should then have the same amount of thermal broadening. This actually usually isn't the case, because the gas which causes absorption lines occur in different places in the atmospheres of each star. Absorption lines in giants, for example, tend to be causes by gas far out in the cooler atmosphere---and thus narrower lines, while those on dwarfs tend to come from hotter regions nearer the surface---and thus broader lines.
Many of the strongest spectral lines (e.g. Balmer absorption lines and resonance lines of metals) are very sensitive to the surface gravity of the star. This enables a distinction between dwarfs and giants because a giant star's surface gravity is factors of $\sim 100$ lower than that of a dwarf star of the same temperature.
The reason that surface gravity plays a role is via hydrostatic equilibrium; the densities and pressures in a giant star's atmosphere are much lower at a given temperature. If an atom or ion suffers frequent collisions in a high density environment then the absorption cross section can be smeared out by "pressure broadening" - a catch-all term, which refers to a number of mechanisms (Stark effect, van der Waals broadening, collisional broadening), whereby interactions can either perturb the energy levels of atoms and ions or truncate the radiative emission processes.
In main sequence dwarfs, pressure broadening is sufficient to give an appreciable cross section in the line wings and means that the visible lines are formed at a greater range of temperatures than would otherwise be the case. In giant stars, this broadening mechanism is ineffective, even in strong lines, and they are completely dominated by thermal doppler broadening close to the temperature where the line core is formed and this produces a narrower profile overall.