We investigate the entanglement spreading in the anisotropic spin-1/2 Heisenberg (XXZ) chain after a geometric quench. This corresponds to a sudden change of the geometry of the chain or, in the equivalent language of interacting fermions confined in a box trap, to a sudden increase of the trap size. The entanglement dynamics after the quench is associated with the ballistic propagation of a magnetization wavefront. At the free fermion point (XX chain), the von-Neumann entropy S_A exhibits several intriguing dynamical regimes. Specifically, at short times a logarithmic increase is observed, similar to local quenches. This is accurately described by an analytic formula that we derive from heuristic arguments. At intermediate times partial revivals of the short-time dynamics are superposed with a power-law increase S_A t^\alpha, with \alpha<1. Finally, at very long times a steady state develops with constant entanglement entropy. As expected, since the model is integrable, we find that the steady state is non thermal, although it exhibits extensive entanglement entropy. We also investigate the entanglement dynamics after the quench from a finite to the infinite chain (sudden expansion). While at long times the entanglement vanishes, we demonstrate that its relaxation dynamics exhibits a number of scaling properties. Finally, we discuss the short-time entanglement dynamics in the XXZ chain in the gapless phase. The same formula that describes the time dependence for the XX chain remains valid in the whole gapless phase.