# 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"
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.yulrizka.com/git/sign-commit-with-pgp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
