9

I've been happily using SourceTree on my Mac for years and rarely had problems. A couple of weeks ago after updating macOS it suddenly stopped working altogether. Whenever I try to clone/fetch/push/pull/whatever to any of my Git repositories, SourceTree either

  1. keeps asking for my SSH key password over and over again immediately after I enter it (if I don't save it in the keychain), or
  2. just hangs forever in the progress window if the password is stored in the keychain.

It's not an issue with the repositories. It's happening for Github too, with the exact same repos and settings that worked before. The key has chmod 400, same as before, and it's the default key ~/.ssh/id_rsa. Tried using the embedded Git in SourceTree and System Git, to no avail. Another app that I switched to in the meantime works normally.

I can't remember exactly which macOS update caused the issues, but I'm now using the latest macOS Catalina 10.15.4 and SourceTree 4.0.1. I wiped the disk completely clean and re-installed everything from scratch due to another problem, but it still doesn't work. I couldn't find anything about new access restrictions that prevent SourceTree from accessing the key itself, or how I could allow access if that's the case. This is driving me nuts, I've switched to another app in the meantime, but I'd really like to continue using SourceTree if it lets me.

EDIT: All my repos are affected by this problem when I'm using SourceTree on macOS. All repos are used by other people as well, it also works for me on my Mac when I use another app. Even SourceTree for Windows on my other laptop, all of those work with the same key.

Paco1
  • 758
  • 6
  • 18
  • 1
    if it might help, when it happens to me I delete all the users in Tools->Options->Authentications so that when you pull or perform any operation that needs authentication, your are asked for it "from scratch", and after its inserted it works fine. – rustyBucketBay May 26 '20 at 15:27
  • 1
    Have you tried generating a new key? is there anyone else accessing that repo having the same issue? – Mario Perez May 26 '20 at 15:27
  • Thanks for your inputs! First topic: I have no Authentications (I guess they are called Accounts in the macOS app). I'm using plain SSH authentication with my default SSH key. Second topic: I tried generating a new key just now, doesn't work either. There are around a dozen other devs also accessing the repos without any issues (though no one has the same hardware/software combo as me), and the other app that I tried still works on all repos with the old key. I'm even using SourceTree for Windows with the same key on the same repo and it works... Only on mac it refuses. – Paco1 May 26 '20 at 22:09
  • Related with long winded notes https://stackoverflow.com/q/47804813/125981 – Mark Schultheiss Dec 09 '22 at 15:27

4 Answers4

16

Thanks for the helpful reply and comments. Turns out SourceTree doesn't add the servers' fingerprints to the ~/.ssh/known_hosts file, and fails silently.

Easy fix - navigate to your repo folder on the command line and run a simple git command, for example:

git fetch origin --dry-run

Nothing will happen since it's a dry run, but the git executable will ask if connecting to the server is ok, and add it to the known_hosts file.

Paco1
  • 758
  • 6
  • 18
6

Nothing worked for me until I added this to my .ssh/config:

UseKeychain yes
spartygw
  • 3,289
  • 2
  • 27
  • 51
2

I faced a similar issue couple of months ago and this is what worked for me. * Open Keychain Access * Under Login/Passwords section look for SourceTree application password * Select the password, right click and delete the password

This time when I entered the password for SourceTree, the app accepted the password without any issues and was saved to the keychain.

There were a couple of things I did that might have contributed to this issue in the first place. I updated my macOS. Around the same time I also enabled two factor authentication in Github. Maybe a conflict between the saved password in the keychain vs the password I was supplying after the update caused the issue. Hope this helps.

GeekyDeveloper
  • 141
  • 1
  • 6
  • Tried deleting it from the keychain, didn't work for me unfortunately. Same behavior as before, either the looping password request or hanging once I tell it to store the password in the keychain again. I'm not using the iCloud keychain btw, so I'm sure the key was really deleted. It's happening on Github and my company's self-hosted Gitlab as well... – Paco1 May 26 '20 at 22:12
2

According to this post, use these commands in your repo folder, works for me well.

git config credential.helper store
git pull

Vít Kapitola
  • 499
  • 1
  • 5
  • 9