Each letter class is broken up further from 0 to 9, with 0 being the hottest. The Sun is a G2 star. The Hertzsprung-Russell diagram. Stars were generally found in certain parts of the diagram, called luminosity classes. Different luminosity classes have different line strengths, so they can be told apart.
Giants have much more extended atmospheres, and hence stronger lines.
The brighter the star, the further away we can see it. This works best for clusters of stars. We know the Sun's mass because of the planets orbiting it. We need orbiting companions in order to measure masses. Fortunately, most stars are really binaries or multiple star systems.