Before a star can become a red giant or a white dwarf, it must burn through the majority of the hydrogen that is in its core. Hydrogen is used up during nuclear fusion, which is the process of creating a helium atom from four hydrogen atoms. The larger a star is, the faster it burns through its hydrogen supply; the sun is expected to last about 10 billion years (with 5 billion years already gone by) on its hydrogen.
A red giant occurs when a star has burned through its hydrogen supply and is now combining helium in its core to produce larger atoms, such as carbon and oxygen. As the star fuses helium, the outer shell greatly expands and cools (while, simultaneously, the inner core is getting smaller and denser); this expansion is what gives the red giant its name as the star greatly increases in size, while the cooling material gives off a distinctive red hue. Eventually this outer material will escape the gravitational pull of the star and dissipate into a nebulae, where the material will eventually be used to form new stars.
The white dwarf phase occurs after the red outer shell has dissipated, leaving behind only a small remnant of the former star. Additionally, the star eventually runs out of helium to fuse; however, the mass of the former star does not produce enough gravity to continue fusing carbon and oxygen into heavier elements, thus the core of a white dwarf is inert. However, the white dwarf is still extremely hot, hence why it gives off a bright white color.
Stars larger than 10 solar mass go through the red giant phase; however, they do have enough gravity to continue fusing oxygen and carbon into larger elements, and thus they skip the white dwarf phase of stellar evolution. Once a star starts to produce iron in its core, a supernova is likely to occur, which is effectively an interstellar explosion in which the core ejects its material in waves. The remnants of a supernova may form a black hole, which is a point so gravitationally dense that nothing can escape it.