# Deploys, rollback, and the Code card

> Find every code task on the Code card (staging and previews) and the Deploys card (live) on Info: mode, commits, deploys, rollback, and builds.

Source: https://docs.wpwaterfall.com/code-tab

Code tasks live on **Info**: the **Code** card on staging and previews, and the **Deploys** card on live. This table says where each task is.

| You want to | Go to |
|---|---|
| See or change the mode (SFTP or Git) | Staging or a preview, **Info**, card **Code**, the **SFTP \| Git** switch. See [Git access](https://docs.wpwaterfall.com/git-access#what-are-the-two-modes) |
| Clone the site | **Info**, card **Code**, **Clone with Git** |
| Add an SSH key for Git | **Account settings**, **Integrations**, **SSH keys**. See [Git access](https://docs.wpwaterfall.com/git-access#how-do-i-add-an-ssh-key-to-my-account) |
| Commit the changes made on staging in SFTP mode, or pull new commits | **Info**, card **Code**: **Commit changes** and **Pull latest commits** |
| Read a commit's diff | **Info**, card **Code**, **Commit history**, **Diff** |
| Connect GitHub, GitLab, Bitbucket, or another Git host | **Environments**, card **External repository**. One repository serves staging and every preview. While one is connected, SFTP and Git through WP Waterfall are off for them |
| Deploy staging to live | Live, **Info**, card **Deploys**, **Deploy to live** (or **Promote to live** in the **Environment details** card). See [Promote to live](https://docs.wpwaterfall.com/code/git-workflow#promote-to-live) |
| Merge a preview into staging | The preview's **Info**, card **Code**, **Merge into staging**, or **Merge** on **Manage environments** |
| Create or delete a preview | **Manage environments**, from the environment switcher |
| Copy a database or uploads between environments | Staging or a preview, **Info**, card **Clone database and files** |
| Roll back live | Live, **Info**, card **Deploys**, then **Roll back** next to an earlier release. See [Roll back](https://docs.wpwaterfall.com/code/git-workflow#roll-back) |
| Read build logs | **Info**, card **Deploys** (on staging, **Deploys** in the **Environment details** card), then the **Builds** tab |
| Set environment variables | **Info**, card **Environment variables** |

## Read commits and builds

The **Code** card lists the commits on the environment's branch with a **Diff** button on each, and the **Deploys** card on live has the same button on every commit that is ready to deploy. The **Deploys** dialog has three tabs: **Releases**, **Commits**, and **Builds** with their logs. The build settings live in `wpwaterfall.yml` in your repository, where you edit them.

## When a deploy changes WordPress

A deploy, a promote, a rollback, or an update that brings another WordPress version finishes the update for you, as steps of the same job: it updates the database, rebuilds the permalinks of the site (and of every site of a network), and then clears the page cache on the server and the edge cache. Without it, pretty links such as `/sample-page/` could answer "Page not found" until someone opened wp-admin. The job's log shows each step. If one fails, the deploy still stands, and the log says what to do: usually open **Settings**, then **Permalinks**, in wp-admin and save.

## API

- `GET /v1/sites/{id}/releases` and `POST /v1/releases/{id}/activate`
- `GET /v1/sites/{id}/commits` and `GET /v1/sites/{id}/commits/{sha}`
- `GET /v1/environments/{id}/builds` and `GET /v1/builds/{id}/log`
- `GET /v1/sites/{id}/promote/preview` and `POST /v1/sites/{id}/promote`
- `GET /v1/environments/{id}/merge-check` and `POST /v1/environments/{id}/merge`
- `GET /v1/environments/{id}/git` and `PUT /v1/environments/{id}/connection-mode` (see [Git access](https://docs.wpwaterfall.com/git-access))

## Related

- [Git access](https://docs.wpwaterfall.com/git-access)
- [Staging, live, and preview environments](https://docs.wpwaterfall.com/environments)
- [Commit changes made over SFTP](https://docs.wpwaterfall.com/sftp-commits)
- [Connect GitHub, GitLab, or Bitbucket](https://docs.wpwaterfall.com/connect-github)
- [How Git deploys work](https://docs.wpwaterfall.com/code/git-workflow)
- [Environment variables](https://docs.wpwaterfall.com/environment-variables)
- [wpwaterfall.yml reference](https://docs.wpwaterfall.com/code/wpwaterfall-yml)
