Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 664
theminer3746 Avatar asked Mar 08 '17 15:03

theminer3746


People also ask

How do I commit in Sourcetree?

Commit filesClick Commit in the toolbar. Select the files to commit in the Pending files panel. Enter a commit message. Click Commit at the bottom of the window.

What is push pull and commit in Sourcetree?

"push" = "send a set of commits and the objects they point to to a remote"; "pull" = "copy a set of commits and referred objects from a remote"; "commit" = "create a new snapshot of the project, pointing to updated directories, files, etc. and one or more parent commits"...


2 Answers

I had a similar issue & I followed @theminer3746 answer to set it up.

I was able to fix the no tty error & have a dialog to enter the password using the following steps

  • Install: https://www.gpg4win.org
  • Load keys into Kleopatra program ([Your homedir]/.gnupg/secring.gpg)
  • Run this command in your terminal: git config --global gpg.program "c:\Program Files (x86)\GnuPG\bin\gpg.exe"
like image 192
ahmad Avatar answered Sep 30 '22 11:09

ahmad


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.

like image 26
theminer3746 Avatar answered Sep 30 '22 11:09

theminer3746