gitatlassian-sourcetreegit-sign

Commit signing using sourcetree on windows


Currently (13th Feb 2018) Sourcetree supports commit signing in Mac version only.

And from this question (since 2013) commit signing still isn't available in Windows version.

So is it possible to sign commit in Windows version of sourcetree?


Solution

  • Well, the answer is yes and no.

    The work around I've figured out is as follow (I assumed that you've already the GPG key setup, if not follow github's tutorial on how to set it up)

    Step 1 Install git shell for Windows

    (If you haven't already)

    Step 2 Make sure sourcetree use system's git

    Press ctrl+, go to git tab and click Use System Gitenter image description here

    Step 3 Configure git to sign every commit (optional)

    From powershell (or you can use the built-in terminal from terminal icon in sourcetree).

    Enter git config commit.gpgsign true - this will configure git to automatically sign all commits in CURRENT repository.

    If you want to sign every commits in EVERY repository use git config --global commit.gpgsign true instead.


    Note If you choose to skip step 3 make sure to add -S every time you commit (git commit -S) or your commit won't be sign.


    Drawback

    Of course this way have a drawback.

    Every time you commit. You have to do it in terminal. If you try to commit using sourcetree's commit button an error will occur

    gpg: cannot open tty `no tty': No such file or directory
    error: gpg failed to sign the data
    fatal: failed to write commit object
    

    Apart from that, you can use every other features sourcetree have (push, pull, fetch, merge etc.) as usual.

    Edit : This drawback has been solved by ahmad's answer.