PHPackages                             drevops/git-artifact - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. drevops/git-artifact

ActivePackage[DevOps &amp; Deployment](/categories/devops)

drevops/git-artifact
====================

Package artifact from your codebase in CI and push it to a separate git repo.

1.6.0(1mo ago)2134.2k↓72%2[1 issues](https://github.com/drevops/git-artifact/issues)GPL-2.0-or-laterPHPPHP &gt;=8.3CI passing

Since Sep 6Pushed 3w ago4 watchersCompare

[ Source](https://github.com/drevops/git-artifact)[ Packagist](https://packagist.org/packages/drevops/git-artifact)[ Docs](https://github.com/drevops/git-artifact)[ GitHub Sponsors](https://github.com/drevops)[ Patreon](https://www.patreon.com/drevops)[ RSS](/packages/drevops-git-artifact/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (47)Versions (39)Used By (0)

  ![Git Artifact logo](logo.png)

Package and push files to a remote repository
---------------------------------------------

[](#package-and-push-files-to-a-remote-repository)

[![GitHub Issues](https://camo.githubusercontent.com/0a668aa4dafcd34c653e929d97e87f783b2dc996408de16424347a423520c38b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f647265766f70732f6769742d61727469666163742e737667)](https://github.com/drevops/git-artifact/issues)[![GitHub Pull Requests](https://camo.githubusercontent.com/dfc127ef11aef25bc88ebb177dcb0c69d2de1fd63b7a718bde59a570481e5427/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f647265766f70732f6769742d61727469666163742e737667)](https://github.com/drevops/git-artifact/pulls)[![GitHub release (latest by date)](https://camo.githubusercontent.com/5de065c0389c2b0c0dc801b38bf410116da13029f697838d72ff7c571422cc3c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f647265766f70732f6769742d6172746966616374)](https://camo.githubusercontent.com/5de065c0389c2b0c0dc801b38bf410116da13029f697838d72ff7c571422cc3c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f647265766f70732f6769742d6172746966616374)[![codecov](https://camo.githubusercontent.com/49bf760a5d287d303bf3c210da07c010a7c7589ba04fceb2208fd7857aab96d2/68747470733a2f2f636f6465636f762e696f2f67682f647265766f70732f6769742d61727469666163742f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d514e42584349424b354a)](https://codecov.io/gh/drevops/git-artifact)[![Total Downloads](https://camo.githubusercontent.com/c60c714ced023b94c0432a4712d3d5c88072fb80b1a1933dba62cacb64e65da0/68747470733a2f2f706f7365722e707567782e6f72672f647265766f70732f62656861742d73637265656e73686f742f646f776e6c6f616473)](https://packagist.org/packages/drevops/git-artifact)[![Docker Pulls](https://camo.githubusercontent.com/02eb9ba6be6f4b712808111e7436a5faaaa7876a0fcaafccbaceb87cb66da6fc/68747470733a2f2f696d672e736869656c64732e696f2f646f636b65722f70756c6c732f647265766f70732f6769742d61727469666163743f6c6f676f3d646f636b6572)](https://hub.docker.com/r/drevops/git-artifact)[![amd64](https://camo.githubusercontent.com/d9302b8e56815ae616e055ec94f623253770190fdb9c2c9dbda2a24acb9325cb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617263682d6c696e7578253246616d6436342d627269676874677265656e)](https://camo.githubusercontent.com/d9302b8e56815ae616e055ec94f623253770190fdb9c2c9dbda2a24acb9325cb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617263682d6c696e7578253246616d6436342d627269676874677265656e)[![arm64](https://camo.githubusercontent.com/82fcd4db0b043bc87bda90e70c197443f831564fc95e1196570e443885d812b5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617263682d6c696e757825324661726d36342d627269676874677265656e)](https://camo.githubusercontent.com/82fcd4db0b043bc87bda90e70c197443f831564fc95e1196570e443885d812b5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617263682d6c696e757825324661726d36342d627269676874677265656e)[![LICENSE](https://camo.githubusercontent.com/abb66d5ba9436eb2800c70987fba7b4cd481cb6134773d761cb0bdc17b4932c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f647265766f70732f6769742d6172746966616374)](https://camo.githubusercontent.com/abb66d5ba9436eb2800c70987fba7b4cd481cb6134773d761cb0bdc17b4932c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f647265766f70732f6769742d6172746966616374)[![Renovate](https://camo.githubusercontent.com/35389190ce58a3690fe850342c1c3fd4f54e4c10ba8996741c8558ee24bf50dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656e6f766174652d656e61626c65642d677265656e3f6c6f676f3d72656e6f76617465626f74)](https://camo.githubusercontent.com/35389190ce58a3690fe850342c1c3fd4f54e4c10ba8996741c8558ee24bf50dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656e6f766174652d656e61626c65642d677265656e3f6c6f676f3d72656e6f76617465626f74)

[![Test PHP](https://github.com/drevops/git-artifact/actions/workflows/test-php.yml/badge.svg)](https://github.com/drevops/git-artifact/actions/workflows/test-php.yml)[![Test Docker](https://github.com/drevops/git-artifact/actions/workflows/test-docker.yml/badge.svg)](https://github.com/drevops/git-artifact/actions/workflows/test-docker.yml)[![CircleCI](https://camo.githubusercontent.com/41e02a29e724cd93ca2feceadf296df56891369b60a8ffd4678c55e5fd05826e/68747470733a2f2f636972636c6563692e636f6d2f67682f647265766f70732f6769742d61727469666163742e7376673f7374796c653d736869656c64)](https://circleci.com/gh/drevops/git-artifact)

[![Vortex Ecosystem](https://camo.githubusercontent.com/08d2ce6f52424a739d03c7df3f08b096f591c5198618d51756c11b2b69bde397/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2546302539462538432538302d566f7274657825323045636f73797374656d2d3243354136383f7374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d363541434243)](https://github.com/drevops/vortex)

---

🌟 With Git Artifact, you can:
-----------------------------

[](#-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](https://github.com/drevops/git-artifact-destination/branches).

🔀 Workflow
----------

[](#-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
--------

[](#️-modes)

### `force-push` mode (default)

[](#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

[](#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

[](#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

[](#use-case-1)

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

[](#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
```

Any branch in the *destination* repository that matches `--cleanup-pattern` and whose last commit is older than `--cleanup-age` days is deleted. 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 - and is matched as a shell glob. 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
--------------

[](#-installation)

### As a standalone binary

[](#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](https://github.com/drevops/git-artifact/releases/latest).

### As a Docker container

[](#as-a-docker-container)

The tool is also published as a multi-architecture (`linux/amd64`, `linux/arm64`) Docker image at [`drevops/git-artifact`](https://hub.docker.com/r/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

[](#image-tags)

Cross-platform (`linux/amd64`, `linux/arm64`) images are built by GitHub Actions and pushed to [Docker Hub](https://hub.docker.com/r/drevops/git-artifact):

- `` (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 `` tag for reproducible deployments and use `canary` only to try out unreleased changes.

### As a Composer dependency

[](#as-a-composer-dependency)

You may also install this tool globally using Composer:

```
composer global require --dev drevops/git-artifact:~1.1
```

#### 📌 Version constraint

[](#-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
--------

[](#️-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=
./git-artifact git@github.com:yourorg/your-repo-destination.git \
  --branch="${DEPLOY_BRANCH}" \
  --push
```

CI providers may report branches differently when packaging is triggered by tags. We encourage you to explore our continuously and automatically tested examples:

- [GitHub Actions](.github/workflows/test-php.yml)
- [CircleCI](.circleci/config.yml)

See extended and fully-configured [example in the Vortex project](https://github.com/drevops/vortex/blob/develop/scripts/vortex/deploy-artifact.sh).

🎛️ Options
----------

[](#️-options)

NameDefault valueDescription`--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`Glob pattern of remote branches eligible for stale cleanup (e.g. `deployment/*`); 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`--fail-on-missing-branch`Fail artifact packaging if source branch cannot be determined. By default, artifact packaging is skipped gracefully`--gitignore`Path to the `.gitignore` file to replace the current `.gitignore``--log`Path to the log file`--message``Deployment commit`Commit message with optional tokens (see below)`--mode``force-push`Mode of artifact packaging: `branch`, `force-push``--no-cleanup`Do not cleanup after run`--now`Internal value used to set internal time`--root`Path to the root for file path resolution. Uses current directory if not specified`--show-changes`Show changes made to the repo during packaging in the output`--src`Directory where source repository is located. Uses root directory if not specified`-V, --version`Display this application version`-h, --help`Display help for the given command`-n, --no-interaction`Do not ask any interactive question`-q, --quiet`Do not output any messages`-v, --verbose`Increase the verbosity of messages: 1 for normal, 2 for more verbose, 3 for debug🧹 Modifying artifact content
----------------------------

[](#-modifying-artifact-content)

`--gitignore` option allows to specify the path to the artifact's `.gitignore`file that replaces existing `.gitignore` (if any) during packaging. Any files no longer ignored by the replaced artifact's `.gitignore` are added into the deployment commit. If there are no no-longer-excluded files, the deployment commit is still created, to make sure that the deployment timestamp is captured.

🏷️ Token support
----------------

[](#️-token-support)

Tokens are pre-defined strings surrounded by `[` and `]` and may contain optional formatter. For example, `[timestamp:Y-m-d]` is replaced with the current timestamp in format `Y-m-d` (token formatter), which is PHP [`date()`](https://www.php.net/manual/en/function.date.php) expected format.

Both `--branch` and `--message` option values support token replacement.

Available tokens:

- `[timestamp:FORMAT]` - current time with a PHP [`date()`](https://www.php.net/manual/en/function.date.php)-compatible `FORMAT`.
- `[branch]` - current branch in the source repository.
- `[safebranch]` - current branch in the source repository with with all non-alphanumeric characters replaced with `-` and lowercased.
- `[tags:DELIMITER]` - tags from the latest commit in the source repository separated by a `DELIMITER`.

Maintenance
-----------

[](#maintenance)

### 🧪 Testing

[](#-testing)

Packaging and deployment of artifacts is a mission-critical process, so we maintain a set of unit, functional and integration tests to make sure that everything works as expected.

You can see examples of the branches created by the Git Artifact in the [example *destination* repository](https://github.com/drevops/git-artifact-destination/branches).

### Lint and fix code

[](#lint-and-fix-code)

```
composer lint
composer lint-fix
```

### Run tests

[](#run-tests)

```
composer test
```

---

*Repository created using  project scaffold template*

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance93

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity90

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 64.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~100 days

Recently: every ~42 days

Total

33

Last Release

34d ago

Major Versions

0.10.0 → 1.0.02025-03-29

PHP version history (4 changes)0.1.0PHP &gt;=5.5.0

0.6.0PHP &gt;=8.1

0.7.0PHP &gt;=8.2

1.1.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/b57b0fd0b96f77f2efa1a1889af0ae607fa139bcc1256e809ee3ebbb30907364?d=identicon)[alexdrevops](/maintainers/alexdrevops)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (223 commits)")[![AlexSkrypnyk](https://avatars.githubusercontent.com/u/378794?v=4)](https://github.com/AlexSkrypnyk "AlexSkrypnyk (118 commits)")[![tannguyen04](https://avatars.githubusercontent.com/u/2858879?v=4)](https://github.com/tannguyen04 "tannguyen04 (7 commits)")

---

Tags

acquiaartefactartifactcomposerdevopsgitpackagephp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/drevops-git-artifact/health.svg)

```
[![Health](https://phpackages.com/badges/drevops-git-artifact/health.svg)](https://phpackages.com/packages/drevops-git-artifact)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M600](/packages/shopware-core)[jolicode/castor

A lightweight and modern task runner. Automate everything. In PHP.

54643.3k4](/packages/jolicode-castor)[laravel/framework

The Laravel Framework.

34.8k543.8M20.5k](/packages/laravel-framework)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[phpro/grumphp

A composer plugin that enables source code quality checks.

4.3k16.7M1.0k](/packages/phpro-grumphp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
