To reset a project entirely to a new code base.
You will need:
- A working Platform.sh project
- Administrator access to it
- Git and SSH configured and accessible
Normally the easiest way to “start fresh” with a project on Platform.sh is to create a new project and optionally delete the old one. However, there are some cases where that may not be viable:
- When using a trial project, deleting the project created with the trial will also delete the trial, even if the trial period has not expired.
- You may want to retain non-code configuration on the project (users, access control, etc.) but still reset all code and data on the project.
These steps will “reset” a project to a fresh state.
Warning: By design, these instructions will result in code and data loss. Do not proceed unless code and data loss is really what you want to do.
1. Remove all services and application data
services.yaml file and remove all lines. Just leave it as an empty file.
Then update your
.platform.app.yaml file. Remove the
relationships block, all
mount declarations and change the
name key to any new value.
Optionally you may remove the
hooks section to make the deploy a bit faster but that is not necessary.
If you have multiple
.platform.app.yaml files, do the same for all of them.
Commit these changes and
git push to the master branch. The environment will rebuild with no services (and thus deleting all of the previously-specified services) and with a blank application container.
Additionally, delete any non-
master branches in Git as they will not work correctly after this process is complete.
2. Select a new code base to deploy
If you have an existing Git repository you wish to deploy, ensure it has the appropriate Platform.sh configuration files.
If you would like to use a one of Platform.sh’s pre-made templates,
git clone the appropriate repository from GitHub to your local computer.
Now reset the Git history in the repository.
cd into the directory you just cloned, then run:
$ rm -rf .git git init git add . git commit -m "Add Platform.sh template."
3. Force push to the project
Add a Git remote for the project to the local Git repository you just created. You can find the Git URL to use in the Web Console by going to the
master environment and selecting the “Git” dropdown. Just copy the remote URL itself, not the full command.
Add that remote to the project (using the Git URL you just copied):
git remote add platform email@example.com:abc123git
Then “Force push” to the master branch of the project:
git push --force -u platform master
That will completely overwrite the
master branch on Platform.sh with the code in your new repository, and set your local branch to track the project’s
master branch so you don’t need to specify it in the future.
The new code will build and deploy a new
master environment with the configuration in Git.
The project will now have a fresh Git history with new code, and completely empty services based on what was defined in the new code base. Any users or environment variables that had been defined previously, however, will remain intact.