Fix subsequent deploys rebase

This PR replaces #2749.