---
# System prepended metadata

title: git-pwApplying Patches from Patchwork

---

# git-pw: Applying Patches from Patchwork

## The Traditional Opensource Projects ...

When working with some "everlasting" open source projects like GCC or Glibc, the communications and patches are sent through email. It is sometimes inconvenient to apply patches that is embedded in an email.

Traditionally, to apply a patch in email, one have to copy the raw email message as a patch file, then use `patch` command to apply it. If there are many patches to apply, it would be time-consuming and frustrating.

## What is Patchwork

Patchwork is a website that collects the mail archives and transfer them into more user-friendly web interface. With patch work, one can view patches and discussions in series. Here is the screenshot of [Glibc patchwork](https://patchwork.ozlabs.org/project/glibc/list/):
![glibc patchwork](https://hackmd.io/_uploads/ByPAPPQR2.png)

## What is git-pw

Another good part of Patchwork is that, it provides APIs to access patches. And [git-pw](https://patchwork.readthedocs.io/projects/git-pw/en/stable/contents/) is a commandline tool that integrate the Patchwork API with git. With git-pw, we can now manage patches in Patchwork with just one single command!

## Installation and Configuration

The following section is a demo of how to install and congifure git-pw for [OzLabs' Patchwork server](https://ozlabs.org/), which collects mail archives for many opensource projects.

### Prepare a Patchwork Account

Firstly, we need to register an account. Go to the [register](https://patchwork.ozlabs.org/register/) page and follow the instructions.

Next, generate an API token in [your user profile page](https://patchwork.ozlabs.org/user/):

![](https://hackmd.io/_uploads/S1_pjvQA2.png)

The token will be used to configure git-pw later.



### Setup and Use git-pw


Assume we want to apply a patch from Glibc, say ["Fix build with GCC 13 _FloatN, _FloatNx built-in functions"](https://patchwork.ozlabs.org/project/glibc/patch/c85488c9-a2c1-61d0-1a41-46d71b0145e@codesourcery.com/)

Let's clone the Glibc to a new driectory and checkout to 2.35 release (where the patch doesn't exist in the tree).

```
$ git clone https://sourceware.org/git/glibc.git
$ cd glibc
$ git checkout release/2.35/master
```

We can install git-pw with `pip`:

```
$ pip install git-pw
```

And configure the Patchwork:

```
$ git config pw.server https://patchwork.ozlabs.org/api/1.2
$ git config pw.token <TOKEN>
```

Replace the `<TOKEN>` with the one generated in above.

:::info
The API version can be found by mapping the Patchwork server version in [about/ page](https://patchwork.ozlabs.org/about/) and [Patchwork documentation.](https://patchwork.readthedocs.io/en/stable-3.0/api/rest/#supported-versions).
For example, by the time this post is written, the OzLab Patchwork version is 2.2, so the latest supported API version is 1.2.
:::

The last step is to find patch ID from the patch work. Just click the patch ID from the patch web page, the ID will be copied to your clipboard:

![](https://hackmd.io/_uploads/SkER6Pm0n.png)

Then apply the patch with the following command:

```
$ git-pw patch apply 1697558
Applying: Fix build with GCC 13 _FloatN, _FloatNx built-in functions [committed]
```

Now the patch is applied!

