The major morphological features of a galaxy are thought to be determined by the assembly history and net spin of its surrounding dark halo. In the simplest scenario, disc galaxies form predominantly in haloes with high angular momentum and quiet recent assembly history, whereas spheroids are the slowly rotating remnants of repeated merging events. We explore these assumptions using 100 systems with halo masses similar to that of the Milky Way, identified in a series of cosmological gasdynamical simulations: the Galaxies–Intergalactic Medium Interaction Calculation (gimic). At z= 0, the simulated galaxies exhibit a wide variety of morphologies, from dispersion-dominated spheroids to pure disc galaxies. Surprisingly, these morphological features are very poorly correlated with their halo properties: discs form in haloes with high and low net spin, and mergers play a negligible role in the formation of spheroids, whose stars form primarily in situ. With hindsight, this weak correlation between halo and galaxy properties is unsurprising given that a minority of the available baryons (∼40 per cent) end up in galaxies. More important to morphology is the coherent alignment of the angular momentum of baryons that accrete over time to form a galaxy. Spheroids tend to form when the spin of newly accreted gas is misaligned with that of the extant galaxy, leading to the episodic formation of stars with different kinematics that cancel out the net rotation of the system. Discs, on the other hand, form out of gas that flows in with similar angular momentum to that of earlier accreted material. Gas accretion from a hot corona thus favours disc formation, whereas gas that flows ‘cold’, often along separate, misaligned filaments, favours the formation of spheroids. In this scenario, many spheroids consist of the superposition of stellar components with distinct kinematics, age and metallicity, an arrangement that might survive to the present day given the paucity of major mergers. Since angular momentum is acquired largely at turnaround, morphology depends on the early interplay between the tidal field and the shape of the material destined to form a galaxy.