Red giant stars are what result when stars such as our Sun reach the end of their main-sequence phase. The mechanism involved is very exact and also depends on the mass of the main-sequence star to begin with.
The term "main-sequence" refers to stars that produce heat and light from the nuclear fusion of hydrogen into helium within their cores. This process can last for billions of years, but, as each stellar object contains a finite amount of hydrogen, eventually it will all be used up, heralding the end of this main-sequence period.
Typically, for stars between 0.3 and 8 solar masses, when the core stops this nuclear fusion, it begins to collapse under its own gravity. This then has the effect of drawing the outer layers (which still contain hydrogen) into an area of the star where nuclear fusion can initiate again, utilising this source of hydrogen.
This process has the effect of increasing the star's brightness by anything up to a factor of 10,000. The outer layers then expand to a huge size. This greatly increased surface area causes the star's surface temperature to drop - and a cooler star equals a redder colour. It has entered the first phase of being a red giant star.
A completely new process occurs during this phase. Because the energy generated in the outer layers is brought to the surface by convection, matter deep in the star (but not its core) comes to the surface too. This is called, rather colourfully, "dredge-up".
This is a reference to part of something called the "Hertzsprung-Russell Diagram", which is a kind of graph depicting the life cycle of stars. Red giant stars, for a time, inhabit the horizontal branch, so-called because they occupy a horizontal line within this graph. Some new processes now take place, varying according to the mass of the star.
When the star is 2 solar masses or less, the core will continue to collapse until it is stopped by a mechanism called "electron-degeneracy pressure". The core then heats up until it reaches a temperature of around 100,000,000° Kelvin. At this point, it is hot enough to start fusing helium into carbon, which it does very suddenly in a process called a "helium flash". For more massive stars, this process occurs much more slowly and there is no "flash".
For stars with greater than 8 solar masses, once the helium has been fully converted into carbon, the core collapses again, thus bringing helium from the outer layers into play, initiating further fusion into carbon. Thus it has a helium shell and, on top of that, a hydrogen shell. Such a star is said to have entered the "asymptotic giant branch".
This process results in the build up of a carbon-oxygen core.
Stars less than 8 solar masses don't enter this phase, merely shedding their outer layers, to become a white dwarf.
By comparison to the length of time a star is within the main-sequence, both the aforementioned phases of a red giant star are very brief, by cosmological standards - in the order of about one billion years.