After you add your public key to your account, you can sign individual commits manually, or configure Git to default to signed commits.
-
Add -S flag to any commit you want to sign:
git commit -S -m "My commit message"
-
Enter the passphrase of your GPG key when asked.
-
Push to an online git repository (GitHub, GitLab, ...) and check that your commits are verified.
git config --global commit.gpgsign true
Source: GitLab Docs - https://docs.gitlab.com/ee/user/project/repository/gpg_signed_commits/#sign-your-git-commits