Fix subsequent deploys rebase

This PR replaces #2749. Fixes #2720.