When a crystal is subjected to a periodic potential, under certain circumstances (such as when the period of the potential is close to the crystal periodicity; the potential is strong enough, etc.) it might adjust itself to follow the periodicity of the potential, resulting in a, so called, commensurate state. Such commensurate-incommensurate transitions are ubiquitous phenomena in many areas of condensed matter physics: from magnetism and dislocations in crystals, to vortices in superconductors, and atomic layers adsorbed on a crystalline surface. Of particular interest might be the properties of topological defects between the two commensurate phases: solitons, domain walls, and dislocation walls. Here we report a commensurate-incommensurate transition for graphene on top of hexagonal boron nitride (hBN). Depending on the rotational angle between the two hexagonal lattices, graphene can either stretch to adjust to a slightly different hBN periodicity (the commensurate state found for small rotational angles) or exhibit little adjustment (the incommensurate state). In the commensurate state, areas with matching lattice constants are separated by domain walls that accumulate the resulting strain. Such soliton-like objects present significant fundamental interest, and their presence might explain recent observations when the electronic, optical, Raman and other properties of graphene-hBN heterostructures have been notably altered.