> For the complete documentation index, see [llms.txt](https://til.yulrizka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.yulrizka.com/git/sign-commit-with-pgp.md).

# sign commit with pgp

Make sure you setup A PGP key on your local machine. See [this article](/unix/encryption-with-gpg.md) to set it up

Make sure you have a key that matched the email that you used for the commit. (eg: `username@users.github.com`

add `-S` flag when you want to sign the commit

```
$ git commit -S -m "your commit message"
# Creates a signed commit
```

or add enable it by default

`Tell git which key to use`

```
git config --global user.signingkey ABC123
```

```
git config --global commit.gpgsign true
```

If you are having issue, `GIT_TRACE=1` with your git comment

```
GIT_TRACE=1 git commit -S -m "your commit message"
```
