Package and push files to a remote repository
π With Git Artifact, you can:
π¦ Assemble a code artifact locally or in CI
π§Ή Exclude any unwanted files using a deployment .gitignore
π€ Transfer the final artifact to a destination Git repository for deployment
π Choose between force-push or branch modes to fit your workflow
See example of deployed artifact
in Artifact branches.
π Workflow
1οΈβ£ π§βπ» Develop in the source repository
2οΈβ£ π¦ CI installs dependencies and runs git-artifact to package and push code to destination repository
3οΈβ£ π Hosting receives the code artifact and triggers a deployment
ποΈ Modes
force-push mode (default)
Push the packaged artifact to the same branch in the destination repository.
This will carry over the branch history from the source repository and will overwrite
the existing branch history in the destination repository.
==================================================
π Run 1
==================================================
Local repo Remote repo
+------------------+
| Artifact commit | π₯ New commit
+------------------+
+-----------+ +------------------+
| Commit 2 | | Commit 2 | \
+-----------+ == π¦ ==> +------------------+ ) π Source commit
| Commit 1 | | Commit 1 | / history preserved
+-----------+ +------------------+
`mybranch` `mybranch`
π
Branch name identical to source
==================================================
π Run 2
==================================================
Local repo Remote repo
+------------------+
| Artifact commit | π₯ New commit
+------------------+
+-----------+ +------------------+
| Commit 4 | | Commit 4 | \
+-----------+ +------------------+ \
| Commit 3 | | Commit 3 | \
+-----------+ == π¦ ==> +------------------+ ) π Source commit
| Commit 2 | | Commit 2 | / history preserved
+-----------+ +------------------+ /
| Commit 1 | | Commit 1 | /
+-----------+ +------------------+
`mybranch` `mybranch`
π
Branch name identical to source
Use case
Forwarding all changes in the source repository to the destination
repository as-is for every branch: for example, a commit in the source
repository branch feature/123 would create a commit in the destination
repository branch feature/123. The next commit to the source repository
branch feature/123 would update the destination repository branch
feature/123 with the changes, but would overwrite the last "artifact commit".
branch mode
Push the packaged artifact to the new branch in the destination repository.
This will carry over the branch history from the source repository to a
dedicated branch in the destination repository. The follow-up pushes to the
branch in the destination repository will be blocked.
==================================================
π Run 1
==================================================
Local repo Remote repo
+------------------+
| Artifact commit | π₯ New commit
+------------------+
+-----------+ +------------------+
| Commit 2 | | Commit 2 | \
+-----------+ == π¦ ==> +------------------+ ) π Source commit
| Commit 1 | | Commit 1 | / history preserved
+-----------+ +------------------+
`mybranch` `deployment/1.2.3`
tagged with
`1.2.3`
π π
Tagged branch New branch based on tag
==================================================
π Run 2
==================================================
Local repo Remote repo
+------------------+
| Artifact commit | π₯ New commit
+------------------+
+-----------+ +------------------+
| Commit 4 | | Commit 4 | \
+-----------+ +------------------+ \
| Commit 3 | | Commit 3 | \
+-----------+ == π¦ ==> +------------------+ ) π Source commit
| Commit 2 | | Commit 2 | / history preserved
+-----------+ +------------------+ /
| Commit 1 | | Commit 1 | /
+-----------+ +------------------+
`mybranch` `deployment/1.2.4`
tagged with
`1.2.4` π New tag 1.2.4
π π
Tagged branch New branch based on a new tag
with a new tag
Use case
Creating a new branch in the destination repository for every tag
created in the source repository: for example, a tag 1.2.3 in the source
repository would create a branch deployment/1.2.3 in the destination
repository. The addition of the new tags would create new unique branches in the
destination repository.
Cleanup of stale branches
In branch mode the destination repository accumulates a new branch for every
deployment. Enable --cleanup-stale to remove old ones automatically after a
successful push:
./git-artifact git@github.com:yourorg/your-repo-destination.git \
--mode=branch \
--branch="deployment/[tags:.]" \
--cleanup-stale \
--cleanup-pattern="deployment/*" \
--cleanup-age=3
Each --cleanup-pattern value is either a comma-separated list of shell globs
(e.g. feature/*,bugfix/*) or a single regular expression wrapped in slashes
(e.g. /^feature\/[^\/]+$/). The option is also repeatable, so patterns can be
supplied across several flags or straight from an environment variable. A branch
in the destination repository is deleted when it matches any of the patterns
and its last commit is older than --cleanup-age days. The branch that was just
pushed and the destination repository's default branch are never deleted.
--cleanup-pattern is required - it is the only way to identify the branches
created by your deployments. Add --dry-run to preview deletions without
performing them.
Because deletion uses standard Git, this works with any remote (GitHub, GitLab,
Bitbucket, self-hosted), not only GitHub.
π₯ Installation
As a standalone binary
This tool is intended to be used as a standalone binary. You will need to
have PHP installed on your system to run the binary.
Download the latest release from the GitHub releases page.
Verify the downloaded binary
Each release signs the checksum of the git-artifact binary with GPG and records a GitHub build attestation for it. Verify a release that lists SHA256SUMS and SHA256SUMS.asc among its assets:
Download the binary of the latest release:
curl -fsSLO https://github.com/drevops/git-artifact/releases/latest/download/git-artifact
Verify the binary with GitHub CLI:
gh attestation verify git-artifact --repo drevops/git-artifact
Or verify it with GPG:
BASE=https://github.com/drevops/git-artifact/releases/latest/download
RAW=https://raw.githubusercontent.com/drevops/git-artifact/main
curl -fsSLO $BASE/SHA256SUMS
curl -fsSLO $BASE/SHA256SUMS.asc
curl -fsSLO $RAW/release-key.asc
gpg --show-keys --with-fingerprint release-key.asc
gpg --import release-key.asc
gpg --verify SHA256SUMS.asc SHA256SUMS
sha256sum -c SHA256SUMS # macOS: shasum -a 256 -c SHA256SUMS
Confirm that gpg --verify reports a good signature from the key with this fingerprint:
1468 C246 213B 8658 33BE 4A60 5F86 D116 C8B2 2A96
gpg also warns that the key isn't certified with a trusted signature. That warning is normal for a newly imported key, and the fingerprint match is the check that counts.
Make the verified binary executable:
chmod +x git-artifact
As a Docker container
The tool is also published as a multi-architecture (linux/amd64, linux/arm64) Docker image at drevops/git-artifact, with git and an SSH client bundled in - no local PHP required. Mount your source repository at /app and pass the same arguments you would pass to the binary:
docker run --rm \
-v "${PWD}":/app \
-e GIT_AUTHOR_NAME="Deployer" -e GIT_AUTHOR_EMAIL="deployer@example.com" \
-e GIT_COMMITTER_NAME="Deployer" -e GIT_COMMITTER_EMAIL="deployer@example.com" \
drevops/git-artifact \
https://github.com/yourorg/your-repo-destination.git --branch=main
The GIT_AUTHOR_* and GIT_COMMITTER_* variables set the identity for the deployment commit. To push to an SSH remote, also mount your SSH credentials read-only:
docker run --rm \
-v "${PWD}":/app \
-v "${HOME}/.ssh":/root/.ssh:ro \
-e GIT_AUTHOR_NAME="Deployer" -e GIT_AUTHOR_EMAIL="deployer@example.com" \
-e GIT_COMMITTER_NAME="Deployer" -e GIT_COMMITTER_EMAIL="deployer@example.com" \
drevops/git-artifact \
git@github.com:yourorg/your-repo-destination.git --branch=main
Image tags
Cross-platform (linux/amd64, linux/arm64) images are built by GitHub Actions and pushed to Docker Hub:
<version> (e.g. 1.2.3) - published when a release tag is created on GitHub.
latest - published when a release tag is created on GitHub.
canary - published on every push to the main branch (latest unreleased changes).
Pin to a specific <version> tag for reproducible deployments and use canary only to try out unreleased changes.
As a Composer dependency
You may also install this tool globally using Composer:
composer global require --dev drevops/git-artifact:~1.1
π Version constraint
When using git-artifact in CI/CD scripts, we recommend using Tilde Version Range Operator to ensure stability.
The tilde constraint allows patch updates (e.g., 1.0.0 β 1.1.1) but blocks minor version updates (e.g., 1.1.0 β 1.2.0).
This ensures that:
- Security fixes and bug patches are automatically applied
- CI/CD pipelines remain stable - no unexpected breaking changes
- Minor version updates are blocked - these may introduce behavioral changes that could affect deployments
This is especially important in CI/CD environments where deployment reliability is critical and changes should be tested before adoption.
βΆοΈ Usage
./git-artifact git@github.com:yourorg/your-repo-destination.git
This will create an artifact from current directory and will send it to the
specified remote repository into the same branch as a current one.
Avoid including development dependencies in your artifacts. Instead, configure
your CI to install production-only dependencies, export the resulting code,
and use that as the artifact source. See our CI examples below.
Call from the CI configuration or deployment script:
export DEPLOY_BRANCH=<YOUR_CI_PROVIDER_BRANCH_VARIABLE>
./git-artifact git@github.com:yourorg/your-repo-destination.git \
--branch="${DEPLOY_BRANCH}"
CI providers may report branches differently when packaging is triggered by tags.
We encourage you to explore our continuously and automatically tested examples:
See extended and
fully-configured example in the Vortex project.
ποΈ Options
| Name |
Default value |
Description |
--ansi |
|
Force ANSI output. Use --no-ansi to disable |
--branch |
[branch] |
Destination branch with optional tokens (see below) |
--cleanup-age |
7 |
Age in days after which a matching remote branch is considered stale; used with --cleanup-stale |
--cleanup-pattern |
|
Remote branches eligible for stale cleanup; repeatable, each value a comma-separated glob list or a /regex/; a branch matching any is eligible; required with --cleanup-stale |
--cleanup-stale |
|
Delete stale remote branches that match --cleanup-pattern and are older than --cleanup-age days |
--dry-run |
|
Run without pushing to the remote repository |