Signing and Verifying Git Commits on the Command Line and GitHub

Поділитися
Вставка
  • Опубліковано 27 сер 2024

КОМЕНТАРІ • 50

  • @NickJanetakis
    @NickJanetakis  3 роки тому +7

    There's 3 different types of errors you might get when watching this video. Here's how to solve them.
    ---
    If you get fatal: failed to write commit object
    and you're using WSL 2 you'll want to add, export GPG_TTY="$(tty)" to your ~/.bashrc or equivalent file.
    ---
    If you're following along and get a "gpg failed to sign the data" error at 1:34, it will be resolved at 5:44.
    Turns out git will default to using your configured git email as a default gpg key if you don't explicitly set the signingkey option that we define at 5:44. I didn't know it did that at the time of recording the video. In my case it worked on video because my email address is the same for both values. Chances are it will work for you too, but if you happen to use different emails for both values then you will encounter the above error until you set your signingkey (which we do at 5:44).
    Thanks @stillFLiP
    for bringing this up in a comment!
    ---
    As of mid-2021 the default gpg key server went offline so the search / receive commands will likely fail unless you change your keyserver. I've been using Ubuntu's server. I've made this update on the blog post version of the video at nickjanetakis.com/blog/signing-and-verifying-git-commits-on-the-command-line-and-github. Search the page for "offline" and you'll find the update on how to customize your keyserver.

    • @_maxt
      @_maxt 3 роки тому +1

      I'm macOS. I had to add this to get it working: export GPG_TTY=$(tty)

  • @pwbandwidth
    @pwbandwidth 3 роки тому +1

    Oh wow, I was just looking at your Docker Flask repo when I found this. Small world!

  • @CocolinoFan
    @CocolinoFan 2 місяці тому +1

    Thank you for the video. It was very useful ❤

  • @Oswee
    @Oswee 3 роки тому +2

    Man... this is gold. Thank you for making these. :) Greetings from Latvia. :)

    • @NickJanetakis
      @NickJanetakis  3 роки тому +1

      No problem, happy to hear it was useful to you.

    • @uriahjeremiah174
      @uriahjeremiah174 3 роки тому

      I dont mean to be offtopic but does anybody know a tool to get back into an instagram account??
      I was dumb forgot my password. I would appreciate any help you can offer me!

    • @Oswee
      @Oswee 3 роки тому

      @@uriahjeremiah174 Use your email to restore forgotten password or don't be an evil.

  • @jodarove
    @jodarove 5 місяців тому +2

    Thank you for the video! It was really helpful!

  • @ip-olvs
    @ip-olvs 2 роки тому +2

    Hey Nick. Thanks for this. Helped me a lot! Got my sub!

  • @divinegoddess3060
    @divinegoddess3060 3 місяці тому +1

    Sir you are awesome!! thank you so much

  • @bvbianca
    @bvbianca 2 роки тому +2

    thank you so much, very well explained :)

  • @vegotech
    @vegotech Рік тому +1

    Special thanks for you, thank you for you efforts very well explained

  • @jromero_
    @jromero_ 5 місяців тому

    Hi Nick! Thank you for the video! I have one follow-up question. I have two computers, the work computer and my personal computer. To sign my commits, do I need to create a GPG key in each computer? or it's enough to create one key and copy it to the other computer? is that even possible? Thank you!

    • @NickJanetakis
      @NickJanetakis  5 місяців тому +1

      Hi, no problem. You can export and import your key on a 2nd device as an "easy" solution. It'll work. Alternatively there's a deeper rabbit hole around creating subkeys but that's not something I ever explored.

    • @jromero_
      @jromero_ 5 місяців тому +1

      @@NickJanetakis thank you for the quick response! Ohh go it, thank you!

  • @elrisitas8508
    @elrisitas8508 3 роки тому +1

    wow nick another great vid!

  • @MisalRaj
    @MisalRaj 2 роки тому +1

    Thanks for this :)

  • @maximianum
    @maximianum 4 місяці тому +1

    ctrl L ?!

  • @dhruvavala4094
    @dhruvavala4094 3 роки тому

    I added gpg keys and followed the steps but they are still not verified

    • @NickJanetakis
      @NickJanetakis  3 роки тому

      Did you update your gitconfig file to include the "user" file, or alternatively put those config settings in your gitconfig directly?

  • @Lord0lives
    @Lord0lives 3 роки тому

    This helped getting Verified for my commits to GitHub, but when I run "get log --show-signature" I get "gpg: Can't check signature: No public key".

    • @NickJanetakis
      @NickJanetakis  3 роки тому

      Did you import the public key of the person who signed the commit?

    • @Lord0lives
      @Lord0lives 3 роки тому

      Turns out I didn't have gpg configured for git. I fixed it by running this command: git config --global gpg.program "

    • @NickJanetakis
      @NickJanetakis  3 роки тому

      @@Lord0lives Ah. I didn't have to do that. What OS are you using?

  • @mr.o5577
    @mr.o5577 2 роки тому

    I am using the WSL2 on windows 11, I've followed all the steps and even went further looking online but I seem not to be able to fix my issue. I am getting these error messages:
    error: gpg failed to sign the data
    fatal: failed to write commit object
    I've added everything in my .gitconfig file, sent the gpg key to the server using the new method in your blogpost but yet I am having this issue since, please can you help me with this?

    • @NickJanetakis
      @NickJanetakis  2 роки тому +1

      Hi, Which WSL 2 distro are you using? What command are you running to produce the error? Also, I know this is asking a lot but do you happen to have a spare Windows 10 box where you can test this on? Just asking because I haven't used Windows 11 and it's hard to say if that's a variable here.

    • @mr.o5577
      @mr.o5577 2 роки тому

      @@NickJanetakis Hello, thank you for replying to me, many don't and just ignore so thanks a lot.
      So I am using Ubuntu 20.04 LTS and I am using the $ git commit -S -m "msg"
      I thing the windows 11 and 10 work the same under the hood, just the design is different and a bit faster too.

    • @mr.o5577
      @mr.o5577 2 роки тому

      BTW i have zsh as my shell, would it affect it maybe?

    • @NickJanetakis
      @NickJanetakis  2 роки тому +1

      @@mr.o5577 It should be ok, I am using zsh now and have no issues. I have to wonder if it's because GPG_TTY isn't set in your shell environment. What if you set this line in your .zshrc file? github.com/nickjj/dotfiles/blob/678765c7611af9e78a0fdb16a56b346429342407/.config/zsh/.zshrc#L102 , I have a feeling it's this.

    • @mr.o5577
      @mr.o5577 2 роки тому

      @@NickJanetakis I will give it a try right now, thank you for taking the time. Be blessed man