DEV Community

Cover image for How to Sign Commits in Git for Fish Shell
Magesh Babu
Magesh Babu

Posted on • Updated on

How to Sign Commits in Git for Fish Shell

Hi there 👋!

Prerequisite:

  • GPG Installed
  • Git Installed

Fish Shell

  • Generating GPG Key

gpg --full-gen-key

Alt Text

  • After generation of your GPG Key, run gpg --list-secret-keys --keyid-format LONG to list your GPG Keys

Alt Text

  • Now Copy The ID like this

Alt Text

  • Tell Git about your signing Key, make sure that you have configured git name and email

git config --global user.signingkey ED267DF4249ACCC3

git config --global gpg.program (which gpg)

git config --global commit.gpgsign true

Here ED267DF4249ACCC3 is my GPG key ID, replace it with yours.

  • Now set The value of GPG_TTY value.

set -gx GPG_TTY (tty)

  • Add the above line to your config.fish file which is located in $HOME/.config/fish/config.fish

  • Now let us test if our GPG works by running

echo "hello" | gpg --clearsign

SIGNED_ECHO

  • If it prompts password for using your GPG key (if any) and generates a sign like above, then your GPG Sign is configured successfully to sign commits

  • To sign a commit git commit -S -m "your message"

Alt Text

-You can check for Sign by running git log --show-signature -1

  • To get verified, you must add your GPG Key to your github account.

  • Export the GPG Public by running gpg --armor --export ED267DF4249ACCC3 remember to replace ED267DF4249ACCC3
    with your own.

Alt Text

  • Visit GitHub, login and click your profile icon, select settings

Alt Text

  • In the user settings sidebar, click SSH and GPG keys.

USEE

  • Select SSH And GPG Keys

  • Click the add GPG key button

ADD_GPG_KEY

  • Paste the GPG that we have copied.
    PASTE

  • Click the add GPG Key button.

  • Now your commits that are signed with it are shown as verified in GitHub 😃

Will Link post for windows CMD and Bash below after ASAP! 🤓

Thanks for reading the Post!, Have a nice day!! 😄

Top comments (1)

Collapse
 
mrcodekiddie profile image
Muthu Kumar • Edited


git config --global user.signingkey (gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{split($0,a,"/"); print a[2]}' | awk '{split($0,a," "); print a[1]}')

Meme image saying "No Need to thank me"