During morphogenesis and cancer metastasis, grouped cells migrate through tissues of dissimilar stiffness. Although the influence of matrix stiffness on cellular mechanosensitivity and motility are well-recognized, it remains unknown whether these matrix-dependent cellular features persist after cells move to a new microenvironment. Here, we interrogate whether priming of epithelial cells by a given matrix stiffness influences their future collective migration on a different matrix – a property we refer to as the ‘mechanical memory’ of migratory cells. To prime cells on a defined matrix and track their collective migration onto an adjoining secondary matrix of dissimilar stiffness, we develop a modular polyacrylamide substrate through step-by-step polymerization of different PA compositions. We report that epithelial cells primed on a stiff matrix migrate faster, display higher actomyosin expression, form larger focal adhesions, and retain nuclear YAP even after arriving onto a soft secondary matrix, as compared to their control behavior on a homogeneously soft matrix. Priming on a soft ECM causes a reverse effect. The depletion of YAP dramatically reduces this memory-dependent migration. Our results present a previously unidentified regulation of mechanosensitive collective cell migration by past matrix stiffness, in which mechanical memory depends on YAP activity.