GitLab(9.5) recently introduced GPG commit verification. On Ubuntu 16.04.x gpg2 is installed and can be used instead of gpg which is in the latest docs published for GPG with 9.5 release.

All good if you use gpg2 instead of gpg, but the problem starts when we sign the commit:

git commit -S -m "sign the commit"

Error thrown maybe vary, but common one is:

gpg: skipped "XTTXXXX": secret key not available
gpg: signing failed: secret key not available
error: gpg failed to sign the data
fatal: failed to write commit object

This does not mean you don’t have the secret key, its because git is using gpg instead of gpg2. This command will fix it, and add it to gitconfig file.

git config --global gpg.program gpg2

Git GPG2

And try to commit again, it will work.