Skip to content

Developers · Build with AI

Undoing a Change

Last updated 18 November 2026

Every way to undo a change on an Insites site: revert a GitHub commit, restore one file, and what happens when a deploy fails.

Sometimes a change goes wrong and you need your files back as they were. This page explains every way to undo a change on an Insites site, what each one really does, and the habits that make undoing easy. You do not call the tools yourself: describe what you want in plain language and your AI picks the right tool. See CloudShell Tools for the full list.

Choose the Right Way

The right way to undo depends on how the change reached your site.

How the change went inHow to undo it
A push to the GitHub branch your site watchesRevert the commit, or commit just one file as it was before. See the next two sections.
A direct deploy by your AI, or an edit in the Site Admin, on a site connected to GitHubThe change was committed to the repository, so revert the commit or commit the file as it was before, the same as for a push.
A direct deploy by your AI, without GitHubDeploy your own older copy of the file again. If you have no copy, CloudShell may hold one for 30 days, which Insites support can restore.
A file your AI deletedDeploy your own copy of the file again, or commit it back from the repository. CloudShell keeps a 30-day copy before a delete, which Insites support can restore.
A deploy that failed part wayUpload and link deploys are rolled back automatically. For other deploys, check what happened, fix the file and deploy again.

Revert a Commit with GitHub

If your site is connected to a repository through the Insites GitHub App, your AI can revert a commit with the insites_github_revert tool. It needs two things: the site and the commit to undo. Your AI can find the commit with insites_github_commits.

Show me the last five commits. Then revert the most recent one
and tell me when the deploy has finished.

What a Revert Does

  • It looks at the commit you chose and finds how the repository looked just before that commit.
  • It adds one new commit to the branch your site watches. The files in that new commit are exactly the files from just before the chosen commit. The commit message is Revert commit followed by the short commit id.
  • It does not rewrite history. The branch only moves forward and nothing is force-pushed. Every older commit stays in the history, so you can still read it.
  • It deploys like any other push. The tool itself does not deploy, but the new commit lands on the watched branch, and every push to the watched branch deploys automatically. Ask your AI to check the deploy, for example: Did the revert deploy?

Note: A revert puts the whole repository back to how it was before the commit you chose. It is not the same as a standard git revert, which undoes only that one commit. If you revert an older commit, every commit after it is undone too: the changes from those later commits are removed from your files, and the earlier files are deployed. The later commits stay in the history. To undo one change and keep later work, see Undo One File Without Losing Later Work below.

Limits

  • You cannot revert the very first commit in a repository, because there is nothing before it to go back to.
  • If someone else pushes to the watched branch at the same moment, the revert fails instead of overwriting their commit. Ask your AI to list the commits again and try again.
  • Reverting needs the Developer role or above on the site, the same as deploying.

Undo One File Without Losing Later Work

With GitHub

To undo one file and keep every later change, ask your AI to commit that file as it was before:

  1. List recent commits with insites_github_commits and find the last commit where the file was correct.
  2. Read the file as it was at that commit with insites_github_pull. It can read from a branch or from an earlier commit.
  3. Commit that older content with insites_github_push. It lands on the watched branch and deploys automatically.
Find the last commit where app/views/pages/index.liquid was correct.
Read the file as it was in that commit, commit it back to the
watched branch, and confirm the deploy.

Without GitHub

Deploy your own older copy of the file again. Small files go through insites_deploy or insites_sync_file. Large files go through an upload. An upload will not replace a file that CloudShell knows is already there unless you ask it to, so tell your AI that you want to replace the file.

Note: The deployment history records who deployed, when, and how many files. It does not store the contents of your files, so it cannot give you a file back as it was. Keep your own copy, or connect GitHub.

When a Deploy Fails

What happens next depends on how the deploy was started.

DeployWhat happens if it fails
Upload or link deploys: insites_commit_upload, insites_upload_asset, insites_deploy_from_urlRolled back automatically. See below.
insites_deployNo automatic rollback. The tool reports the result of each part of the deploy, and the status is partial if any part failed.
insites_sync_fileNo automatic rollback. A failed sync is recorded in the deployment history.
GitHub pushNo rollback. CloudShell tries the deploy again after 60 seconds, up to three attempts in all, and records the result in the deployment history.

Automatic Rollback for Upload and Link Deploys

Upload and link deploys run as a background job. Your AI checks its progress with insites_deploy_status.

  • Short service problems are retried. The job tries again up to three times before it gives up.
  • A deploy the site rejects is rolled back straight away. Trying again would fail the same way. The deploy is recorded as failed with the site's reason, and files the deploy never wrote are left as they were.
  • A file the deploy replaced is put back from the 30-day copy, byte for byte.
  • A file the deploy created is deleted. CloudShell knows the file was not there before, so it removes it rather than leaving an empty file.
  • A file CloudShell has no record of is emptied, not deleted. This happens to asset and module files, which CloudShell never treats as new, so a rollback never deletes one. It also happens to any file when CloudShell could not read your site before the deploy.
  • If a file was there before but no copy was kept, CloudShell does not guess. It leaves the file as it is and alerts the Insites team. The deploy then shows as failed in the deployment history, with a message that manual recovery is needed.

Fixing Other Failed Deploys

Ask your AI to check the deployment history and the site logs. It can read the error, fix the file and deploy again. If the bad change came from GitHub, push a fix or revert the commit.

Show me the last five deploys and check the logs for errors.
Tell me what failed and fix it.

The 30-Day Copy

When a direct deploy replaces a file that CloudShell knows is on your site, or your AI deletes a file, CloudShell saves a copy of the version being replaced or deleted. The copy is deleted automatically after 30 days.

  • Kept by: insites_deploy, insites_commit_upload, insites_upload_asset, insites_deploy_from_url and insites_delete_file.
  • Not kept by: insites_sync_file, and deploys from GitHub. For GitHub, the repository history is your record.
  • Used automatically when an upload or link deploy fails and is rolled back.

CloudShell knows a file is there in two ways:

  • It deployed the file itself.
  • The file was there when CloudShell last read your site. CloudShell reads the files on your site before its first deploy there, and again once that read is more than 30 days old. So it also knows about files that reached your site another way, such as from GitHub, the Insites CLI or the Site Admin.

The read takes at most 10 seconds and never holds up a deploy. If it fails, the deploy goes ahead, and CloudShell treats a file it has no record of as unknown: it may not copy it, and a rollback empties it rather than deleting it.

Note: CloudShell does not see a file that reaches your site another way after its last read. Until the next read, which can be up to 30 days later, it treats that file as new. If a CloudShell deploy then replaces the file, no copy is kept. If that deploy is an upload or link deploy and it fails, the rollback can delete the file. Asset and module files are not affected. To avoid this, change each file through one route only. For example, if a file came from GitHub, change it through GitHub, not with a direct deploy.

Note: There is no tool your AI can use to restore a file from the 30-day copy. If you need a file back from it, contact Insites support within the 30 days. Tell them the site, the file path, and roughly when the deploy ran.

When the Copy Cannot Be Kept

If CloudShell cannot save the 30-day copy, it refuses to replace or delete the file rather than go ahead with nothing to fall back on. The message names the step that failed, such as reading the file or saving the copy, and the reason. You then have two choices:

  • Keep your own copy first. Read the file from the site or from the repository, save it, and then ask again.
  • Go ahead without a copy. Tell your AI to replace or delete the file without keeping a copy. The reply says that no copy was kept. The old version is then not recoverable by Insites support, so only do this when you have the file elsewhere or do not need it back.

CloudShell still keeps a copy whenever it can, even when you have said it may go without one.

Habits That Make Undoing Easy

  • Connect GitHub. Every change becomes a commit you can review and undo yourself. See Insites GitHub App.
  • Build on staging first. Test every change on a staging site before it goes to production. See Safety Rails for AI Builds and Staging vs. Production.
  • Keep unfinished work off the watched branch. Push work in progress to another branch. Nothing deploys until it is merged into the watched branch.
  • Check the commit list before you revert. Make sure you know which later commits a revert will also undo.
  • Know where the deployment history is. Ask your AI to show recent deploys, so you can see which change to undo.
  • Keep your own copy when you deploy directly. Without GitHub, your own copy is the fastest way back.

Related Pages