Skip to main content

Git Deployer

A utility for automated deployment of generated static websites (documentation, help guides, etc.) using Git.

Advantages

  • Simplicity: Deploy with a single command.
  • Reliability: Uses proven Git mechanisms.
  • Versatility: Suitable for any hosting service that supports Git repositories (GitHub Pages, GitLab Pages, your own server, etc.).
  • Incremental Deployment: Only modified files are transferred.

Installation

python -m pip install git+https://github.com/optinsoft/git-deployer.git

Usage

Initialization (first run)

  1. You generate a static site (for example, using Docusaurus, Sphinx, Jekyll, MkDocs).
  2. Initialize a Git repository in the directory containing the generated site (e.g., _build/html).

Example:

cd _build/html
git init
  1. Using Git, add a new remote repository and specify which remote branch your local branch should track.

Example:

git remote add origin https://github.com/owner/repository.git 
git branch --set-upstream-to origin/main main
  1. Run deploy.
deploy .
  1. The utility publishes the files to the remote repository.

To publish, Git Deployer executes the following commands:

git add .
git commit -m "Site updated: %Y-%m-%d %H:%M:%S"
git push

%Y-%m-%d %H:%M:%S will be replaced by the current date and time, ex.: 2025-09-29 10:44:15

Configuring with deploy_config.yml (alternative initialization)

An alternative initialization method involves creating a deploy_config.yml configuration file in the root directory of your project and then running the deploy _build/html command. If the _build/html directory does not already contain a Git repository and the git_init option has been set in deploy_config.yml, Git Deployer will automatically execute git init. It will then configure the remote repository, branch, and (optionally) the username and email according to the configuration file.

Configuration example:

deploy:
  remote:
    name: 'origin' 
    url: 'https://github.com/owner/repository.git'
  branch: 'master'
  name: owner_name
  email: owner@email
  message: 'new commit at %Y-%m-%d %H:%M:%S'
  git_init: True
  force_push: True

The force_push option allows you to deploy the site to a remote repository using git push --force. This command bypasses the standard safety checks that prevent pushing when the remote history diverges from the local history. If, even with the force_push, you get the error message "remote: error: denying non-fast-forward refs/heads/master (you should pull first)", you need to disable receive.denyNonFastForwards in remote repo. Find the [receive] section within the config file. If denyNonFastForwards is set to true, change it to false. If the setting doesn't exist, you can add it.

[receive]
    denyNonFastForwards = false

You can configure the git commit message. It can contain date and time format specifiers, for example: %Y-%m-%d %H:%M:%S, which will be replaced by the current date and time.

If the project contains multiple sites, each with its own individual deployment settings (remote repository, branch, etc.), you can specify them in the sites section, for example:

deploy:
  sites:
    -
      path: site_to_deploy
      deploy:
        remote:
          name: 'github'
          url: 'https://github.com/owner/site_to_deploy.git'

Everyday deployments

deploy _build/html

Metadata

Release files for git-deployer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-deployer 0.1.0
File Size Uploaded
git_deployer-0.1.0.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for git-deployer 0.1.0
File Interpreter ABI Platform
git_deployer-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.7 kB

Release files / git_deployer-0.1.0.tar.gz

Download URL git_deployer-0.1.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
24849fb35b76b27e93e7fd9094fe0ecd34ea6b4a14152df20ac4d6fa921a615e
BLAKE2b-256 checksum
How to use checksums
808ddd5c57aba7b7091bfafe779360e17f915cff04fc0e990f675fbb0c241da1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / git_deployer-0.1.0-py3-none-any.whl

Download URL git_deployer-0.1.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a5a4951a5dc48f9b0c4b01cadbcc96c696cc5f300142e8859d591c87cb2c8cb
BLAKE2b-256 checksum
How to use checksums
d07de8f0cc480b91a0a8a644e07e1597b6059d8815970314e83d69e2c3a0dc34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page