That sounds like https://git-scm.com/book/en/v2/Git-Tools-Rerere ?