Signing commits in Forgejo
2026-07-05
In Forgejo instance, I rarely seeing people actually use sign feature. And actually, seeing an green checkmark on every commits in every repos is an cool eye candy, and glad it’s pretty simple.
1. Keys requirements
You must already have the SSH and GPG key created and imported to your Forgejo (usually in Profile > Settings > Keys). You may need to check this step-by-step links that to make one or to make sure.
Remember that the docs is adaptable to any Forgejo instances and doesn’t have to be Codeberg, which is also written here for consistency.
The setup would be looked like this:

2. Try to signing commit
After gets the keys requirements set up, it’s time to testing by make a new commit on any repository, by manually adding the -S option every time making a new commit, for example:
git commit -S -m "YOUR_COMMIT_MESSAGE"
And then you can push the commit and see at the Forgejo Web if it’s verified.
If it’s successful, you can make it automatically signing every new commits by running this command:
git config --global commit.gpgsign true

3. Signing all unsigned commits in a repo
If we’re able to signing a new commits, are we able to also signing old commits too? Yes, however it’s not recommended for a repository that already used and have contribution by people, the only hassle is that commit hash will be re-generated and the entire history will be “rewritten”, aside of that, the date, changes and other overall, are not affected at all. So if it’s your personal repo, you can do this.
# https://stackoverflow.com/questions/41882919/is-there-a-way-to-gpg-sign-all-previous-commits/41883164#41883164
# Redo every commit with the -S option.
git filter-branch --commit-filter 'git commit-tree -S "$@";' -- --all
# Pull current repo state.
git pull
# Force push the rewritten history.
# You may change "main" to your current repo branch in case.
git push --force-with-lease origin main:main
That’s it, you now having an wonderful Git commit history.
I spend a hour just to write this whole post lol, my brain just can’t load any words that I wan’t to write on demand.