Yes, under limited circumstances. Per §6b EstG you don't have to tax the profits from the sale (Veräußerung) of a business asset, if:
the sold asset is land or a building or certain other assets
you held the sold asset for the last 6 years
you acquire an asset of the same type within 4–6 years (depends on the asset type)
and possibly other conditions
All stocks bought after 2009 fall under a 25% flat tax ("Abgeltungssteuer") on all capital gains, exluding additional tax through the"Solidaritätszuschlag" and potential church tax. There are otherwise no tax provisions I know of.
Up to 801€ or 1602€ for couples of capital gains can be set as a tax-free "Sparer-Pauschbetrag".
If you save in a "Riester-...
Yes, you can offset capital gains with capital losses. See 1040 Schedule D, you'll see that you list all your investments, gains or losses, and total them up. But while this might be a good tax strategy, it might be a poor investment strategy (selling at a loss). You might be spending a dollar to save a quarter.