To get around the capital gains tax, you need to live in your primary residence at least two of the five years before you sell it. Note that this does not mean you have to own the property for a minimum of 5 years, however. Once you’ve lived in the property for at least 2 years, you’d reach capital gains tax exemption.