# Install gpatch with Homebrew, MacPorts, apk, chocolatey, apt, dnf, Nix, pacman, zypper, scoop, winget

Apply a diff file to an original. Version 2.8 via Homebrew; verified from local package data. Also installable with macports: sudo port install gpatch.

## Install

```sh
sudo av install brew:gpatch
```

Additional install commands:

### macOS

- Homebrew (100%):

```sh
brew install gpatch
```

  Evidence: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install gpatch
```

  Evidence: MacPorts ports tree: devel/gpatch/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- apk (92%):

```sh
sudo apk add patch
```

  Evidence: Alpine Linux edge package indexes: patch from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz

- Debian apt (92%):

```sh
sudo apt install patch
```

  Evidence: Debian stable package indexes: patch from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz

- dnf (92%):

```sh
sudo dnf install patch
```

  Evidence: Fedora Rawhide package metadata: patch from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst

- Nix (92%):

```sh
nix profile install nixpkgs#patch
```

  Evidence: nixpkgs package indexes: patch from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix

- pacman (92%):

```sh
sudo pacman -S patch
```

  Evidence: Arch Linux sync databases: patch from https://geo.mirror.pkgbuild.com/core/os/x86_64/core.db.tar.gz

- zypper (92%):

```sh
sudo zypper install patch
```

  Evidence: openSUSE Tumbleweed package metadata: patch from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst

### Windows

- Chocolatey (92%):

```sh
choco install patch
```

  Evidence: Chocolatey community package catalog: patch from http://community.chocolatey.org/api/v2/Packages?$filter=IsLatestVersion&$select=Id&$top=1000&$skiptoken='11','p4'

- Scoop (92%):

```sh
scoop install main/patch
```

  Evidence: Scoop official bucket manifest trees: bucket/patch.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1

- winget (92%):

```sh
winget install --id GnuWin32.Patch -e
```

  Evidence: Windows Package Manager source index: GnuWin32.Patch from https://cdn.winget.microsoft.com/cache/source.msix

## Package facts

- **Package key:** brew:gpatch
- **Package manager:** Homebrew
- **Version:** 2.8
- **Source summary:** Apply a diff file to an original
- **Homepage:** <https://savannah.gnu.org/projects/patch/>
- **Generated:** 2026-08-03T19:37:03+00:00

## Executables

- patch (alias)

## Install behavior

- Bottle: not available

## Freshness

- Page generated: 2026-08-03
- Package-manager version: 2.8
## Project history and usage

GNU patch applies diff output to original files to produce modified files. It descends from Larry Wall's patch program and became one of the basic tools of Unix source distribution, mailing-list development, and package-manager patch application.

### Project history

The GNU patch README states that this GNU version applies diff files to original files and includes many Free Software Foundation changes: binary and large-file handling, unified diff support, merge behavior, GNU-style backup files, improved RCS and SCCS interaction, GNU option parsing/configure conventions, and better POSIX compliance.

The README also explains why the FSF distributed GNU patch independently: Larry Wall had not released a new version since mid-1988, and he agreed to GNU distribution under the GNU General Public License. GNU bulletins from the 1990s describe patch as GNU's version of Larry Wall's program for applying diff output.

### Adoption history

patch became a standard Unix packaging primitive because source distributions could ship small textual changes instead of whole replacement trees. GNU patch's support for unified diffs, reject files, backup naming, and POSIX/GNU build conventions made it fit naturally into Autotools-era source packages and distribution build recipes.

### How it is used

The GNU diffutils manual shows the common form `patch <patchfile`, with optional original-file and patch-file arguments. If no patch file is supplied, patch reads diff output from standard input; if no input file is supplied, it tries to infer the file to edit from leading patch text.

### Why package nerds care

For package maintainers, GNU patch is infrastructure rather than just a user command. It is the tool behind downstream patch queues, source RPM and Debian patch application, vendor backports, portability fixes, and decades of email-driven source exchange before pull-request platforms normalized repository-hosted review.

### Timeline

- 1984: Larry Wall copyright years begin in the GNU patch README.
- 1988: The GNU patch README says Larry Wall had not released a new version since mid-1988.
- 1989: Free Software Foundation copyright years begin in the GNU patch README.
- 1990s: GNU bulletins list patch as GNU's version of Larry Wall's diff-applying program.
- 1997: GNU FTP archive lists patch 2.5.
- 2009: patch 2.6 adds a regression test suite, merge option, improved rejects, and GPLv3 licensing.
- 2012: patch 2.7 adds `diff --git` format support and path-safety checks.
- 2018: GNU FTP archive lists patch 2.7.6.
- 2025: GNU FTP archive lists patch 2.8.

### Related projects

- GNU diffutils produces the diff output commonly consumed by patch.
- RCS, SCCS, CVS, and later Git all coexist with patch-oriented workflows.
- Git's `git apply` and `git format-patch` continue the patch-file workflow in a repository-aware form.

### Sources

- <https://ftp.gnu.org/gnu/patch/>
- <https://ftp.gnu.org/gnu/patch/patch-2.7.6.tar.xz>
- <https://git.savannah.gnu.org/cgit/patch.git>
- <https://savannah.gnu.org/projects/patch>
- <https://www.gnu.org/bulletins/bull22.html>
- <https://www.gnu.org/software/diffutils/manual/html_node/Invoking-patch.html>


## Security Notes

narrow executable package without higher-risk signals.

- **Geiger risk:** green / low
- narrow executable package without higher-risk signals

## Other Package-Manager Records

- MacPorts - gpatch: normalized package name match | MacPorts ports tree: devel/gpatch/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1
- Debian apt - patch - 2.8-2: installed executable or alias match | Debian stable package indexes: patch from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Apply a diff file to an original | https://savannah.gnu.org/projects/patch/
- Nix - patch: installed executable or alias match | nixpkgs package indexes: patch from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix
- Ubuntu apt - patch - 2.7.6-7build3: installed executable or alias match | Ubuntu 24.04 LTS package indexes: patch from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | Apply a diff file to an original | https://savannah.gnu.org/projects/patch/
- apk - patch - 2.8-r0: installed executable or alias match | Alpine Linux edge package indexes: patch from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | Utility to apply diffs to files | https://www.gnu.org/software/patch/patch.html
- apk - patch-doc - 2.8-r0: installed executable or alias match | Alpine Linux edge package indexes: patch-doc from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | Utility to apply diffs to files (documentation) | https://www.gnu.org/software/patch/patch.html
- dnf - patch - 2.8-5.fc45: installed executable or alias match | Fedora Rawhide package metadata: patch from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst | Utility for modifying/upgrading files | https://savannah.gnu.org/projects/patch/
- pacman - patch - 2.8-1: installed executable or alias match | Arch Linux sync databases: patch from https://geo.mirror.pkgbuild.com/core/os/x86_64/core.db.tar.gz | A utility to apply patch files to original sources | https://www.gnu.org/software/patch/
- zypper - patch - 2.8-3.2: installed executable or alias match | openSUSE Tumbleweed package metadata: patch from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst | GNU patch | https://ftp.gnu.org/gnu/patch/
- Chocolatey - patch: installed executable or alias match | Chocolatey community package catalog: patch from http://community.chocolatey.org/api/v2/Packages?$filter=IsLatestVersion&$select=Id&$top=1000&$skiptoken='11','p4'
- Scoop - main/patch: installed executable or alias match | Scoop official bucket manifest trees: bucket/patch.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1
- winget - GnuWin32.Patch: installed executable or alias match | Windows Package Manager source index: GnuWin32.Patch from https://cdn.winget.microsoft.com/cache/source.msix


## Combined YAML source

View the package source record on GitHub. [combined/gpatch.yml](https://github.com/mxcl/pkgdb/blob/main/combined/gpatch.yml)


## Sources

- pkg.so package database
- Geiger risk classifier
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
