Git-Based Website Deployment Guide: From Repository to Production With a Safe Rollback Workflow
Gitdeploymentdeveloper hostingCI/CDrollbackserver security

Git-Based Website Deployment Guide: From Repository to Production With a Safe Rollback Workflow

QQubit Host Editorial Team
2026-11-20
8 min read

Deploy static, PHP, or Node websites from Git with a practical checklist for secrets, builds, migrations, verification, and safe rollback.

Deploying a website from Git to a hosting server is straightforward when each release has a defined path from commit to production. This guide provides a reusable checklist for static sites, PHP applications, and Node.js services, covering repository access, builds, environment variables, database changes, verification, security, and safe rollback.

Overview

A reliable Git deployment separates the application source code from the production environment. Git stores the versioned code and deployment history; the hosting server provides the runtime, web server, database, DNS, SSL, backups, and operational controls. Your deployment process connects the two without exposing secrets or replacing a working release before the new one has been checked.

The exact commands depend on the hosting environment. A shared hosting account may use a control-panel Git integration, a deployment hook, or SSH commands. A virtual server may use a CI/CD runner, a service manager, containers, or a scripted release process. The principles remain consistent:

  • Deploy a known commit or tagged release rather than an untracked working directory.
  • Keep credentials, API keys, and production configuration outside the repository.
  • Build and test before changing the live application.
  • Make database changes deliberate and, where possible, reversible.
  • Verify the site after deployment and retain a clear rollback path.

Before starting, document the production domain, hosting account, deployment directory, runtime versions, build command, start command if applicable, database connection details, scheduled jobs, writable directories, and the person or system responsible for approving releases. If the domain or DNS is changing as part of the launch, review the domain connection and DNS verification steps separately from the code deployment.

Checklist by scenario

Static website or frontend application

  1. Prepare the repository. Confirm that the main branch contains the intended source, the package lockfile is committed, and the build configuration is documented. Remove local-only files and check that the repository does not contain secrets.
  2. Set the deployment inputs. Record the required runtime and package-manager versions. Define the build command, such as the project’s documented production build command, and identify the output directory, such as dist, build, or another configured path.
  3. Configure access. Use a deploy key or a narrowly scoped machine credential when the server needs to read a private repository. Do not place a personal password or private key in the repository, a public build log, or a client-side environment file.
  4. Build outside the live directory. Fetch the target commit, install dependencies using the lockfile, and run the production build in a temporary or staging location. Treat build warnings as items to review rather than assuming the output is valid.
  5. Publish the artifact. Copy or switch the completed output into the document root only after the build succeeds. A release directory plus a symbolic link to the active release can make switching and rollback safer on servers that support that pattern.
  6. Verify the result. Test the homepage, important routes, asset loading, forms, redirects, canonical host, HTTPS, and any client-side route fallback. Check browser developer tools and server logs for failed requests.

PHP application or WordPress project

  1. Confirm the supported PHP version, required extensions, web-server document root, and dependency manager configuration before deployment.
  2. Fetch the approved commit and install production dependencies without development packages when the project supports that separation.
  3. Keep the environment file outside version control. Confirm database credentials, application keys, cache settings, mail configuration, and filesystem paths on the server.
  4. Back up the database and relevant uploaded files before a release that changes application behavior or schema. A backup is only useful if restoration has been considered and the recovery location is known; use the web hosting backup strategy as a separate recovery checklist.
  5. Run migrations using the framework’s documented production command. Review the migration order and avoid mixing destructive data operations into an untested release.
  6. Clear or rebuild application caches when required, then check login, content creation, uploads, email delivery, scheduled tasks, and administrative functions.

For WordPress, distinguish code deployment from content and media management. Theme and plugin files may be versioned, while uploads and database content usually require their own backup and migration plan. Compare the server requirements with the project using this WordPress hosting requirements checklist.

Node.js application or API

  1. Define the Node.js version, package-manager version, install command, build command, start command, port, and process-management method.
  2. Install dependencies from the lockfile and build in a release directory. Do not assume that a development server is suitable for production.
  3. Provide environment variables through the hosting panel, service manager, deployment system, or a protected server-side file. Only variables explicitly intended for browser use should be included in a client bundle.
  4. Start the new release using the hosting environment’s documented process method. Configure a health endpoint or another lightweight check that confirms the application can respond.
  5. Check logs, response codes, database connectivity, background jobs, and graceful restart behavior before declaring the deployment complete.

Automated CI/CD deployment

Use a pipeline when releases are frequent or several people need the same repeatable process. A practical pipeline can check out a commit, install dependencies, run tests, build an artifact, connect using a deployment key or trusted runner, upload the artifact, run migrations with approval where appropriate, switch the release, and perform a health check. Protect the production branch, require review for deployment configuration, and keep production credentials limited to the environment that needs them.

What to double-check before production

Repository and release identity

Record the commit hash, tag, or build identifier being released. Confirm that the server is pulling the intended repository and branch. A deployment that succeeds technically but uses the wrong branch is still a failed deployment.

Secrets and permissions

Search the repository and build output for passwords, private keys, tokens, and production connection strings. Use separate credentials for development, staging, and production where practical. Deployment accounts should have only the access needed to read the code and update the release. Web-server and application permissions should not make every file writable by the process.

Environment differences

Compare local, staging, and production runtime versions, enabled extensions, operating-system assumptions, filesystem paths, database engines, time zones, and case sensitivity. Many deployment failures come from an application relying on a local setting that was never documented.

Database and data safety

Separate schema changes from code changes when that reduces risk. Prefer migrations that can run while the previous version is still operating, especially where a rollback may be needed. Before changing data, confirm the latest backup, its retention, and the restoration procedure. Do not treat a successful database command as proof that the application is healthy.

DNS, SSL, and caching

If the server, hostname, or origin has changed, verify DNS records and allow for resolver caching rather than repeatedly changing records. Confirm that the certificate covers the production hostname, HTTP redirects to HTTPS as intended, and cached assets reference valid paths. The HTTPS and SSL troubleshooting guide can help isolate certificate, hostname, and mixed-content problems.

Rollback readiness

A rollback should be a known action, not an emergency invention. Keep the previous application release available until the new release passes its observation period. For a release-directory setup, rollback may mean switching the active link to the previous directory and restarting the service. For a simpler setup, retain a known-good archive and document how to restore it. Database rollback needs separate planning; reverting application files does not automatically undo a migration.

Common mistakes

  • Deploying directly from an unreviewed branch: Pin releases to an approved commit or tag and keep the production branch protected.
  • Committing environment files: Add local configuration files to the ignore rules, rotate any exposed secret, and store production values through a protected server mechanism.
  • Building on the server without controlling versions: Pin dependencies and runtime versions so the same commit produces a predictable result.
  • Replacing files in place: A partial upload can leave a mixed release. Build separately and publish atomically where the hosting platform permits it.
  • Skipping a backup before migrations: Take a restorable backup before data changes, not after an error appears.
  • Testing only the homepage: Check authentication, forms, uploads, APIs, payments if applicable, scheduled tasks, redirects, and representative content.
  • Forgetting background processes: Web code may be updated while workers, queues, cron jobs, or long-running Node processes still use the previous release.
  • Assuming rollback fixes everything: Code rollback cannot automatically restore deleted data, changed DNS, sent email, or an incompatible database schema.
  • Leaving deployment keys and logs unmanaged: Review access periodically and ensure logs do not print tokens or complete connection strings.

When to revisit

Use this checklist before the first production release, every significant deployment, and any server replacement or domain change. Revisit the workflow before seasonal planning cycles when release volume, traffic, or staffing may change. Review it after a failed deployment, an incident, a rollback, or a recovery exercise; these events often reveal undocumented assumptions.

Update the guide and deployment scripts when the hosting panel, CI/CD provider, framework, package manager, operating system, or runtime version changes. An annual technical review should confirm that deployment keys still have appropriate scope, backups can be restored, SSL and DNS settings are documented, dependencies are maintained, and the rollback procedure still works. If you are moving the whole site to a different provider, combine this process with the website migration and rollback checklist.

Release-day quick check: approve the commit, confirm the backup, verify secrets and runtime versions, build outside production, run migrations deliberately, publish the release, test critical paths, monitor logs, and keep the previous release available until the result is clear. That sequence turns Git deployment from a file-copying task into a controlled, repeatable production workflow.

Related Topics

#Git#deployment#developer hosting#CI/CD#rollback#server security
Q

Qubit Host Editorial Team

Technical Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.