We study the alignment of galaxies relative to their local environment in SDSS-DR8 and, using these data, we discuss evolution scenarios for different types of galaxies. We defined a vector field of the direction of anisotropy of the local environment of galaxies. We summed the unit direction vectors of all close neighbours of a given galaxy in a particular way to estimate this field. We found the alignment angles between the spin axes of disc galaxies, or the minor axes of elliptical galaxies, and the direction of anisotropy. The distributions of cosines of these angles are compared to the random distributions to analyse the alignment of galaxies. Sab galaxies show perpendicular alignment relative to the direction of anisotropy in a sparse environment, for single galaxies and galaxies of low luminosity. Most of the parallel alignment of Scd galaxies comes from dense regions, from 2...3 member groups and from galaxies with low luminosity. The perpendicular alignment of S0 galaxies does not depend strongly on environmental density nor luminosity; it is detected for single and 2...3 member group galaxies, and for main galaxies of 4...10 member groups. The perpendicular alignment of elliptical galaxies is clearly detected for single galaxies and for members of < 11 member groups; the alignment increases with environmental density and luminosity. We confirm the existence of fossil tidally induced alignment of Sab galaxies at low z. The alignment of Scd galaxies can be explained via the infall of matter to filaments. S0 galaxies may have encountered relatively massive mergers along the direction of anisotropy. Major mergers along this direction can explain the alignment of elliptical galaxies. Less massive, but repeated mergers are possibly responsible for the formation of elliptical galaxies in sparser areas and for less luminous elliptical galaxies.