Configure SourceTree

How do I configure SourceTree to clon my GitLab repo(s)?

1 Like

I don’t think you can right now, @ospena2020. Not unless you request GitLab integration to be added by requesting it on Atlassian’s SourceTree issue tracker.

1 Like

Seems that gitlab support is planned for sourcetree 1.8.1

https://jira.atlassian.com/browse/SRCTREE-1037?src=confmacro

1 Like

So I’ve read: Configure SourceTree

Since then has there been any word that this is going to happen or not?

1 Like

@ospena2020, @KamranMackey, and @haynes,

While Sourcetree doesn’t yet have automatic wizard-like support of gitlab, you can already set it up to work perfectly with gitlab, or any other git server that runs over ssh or https. Here’s how you do it:

Step 1: Browse to your repo and copy the SSH or HTTPS address. I recommend SSH for Sourcetree.

Step 2: Click the Clone / New button.

Step 3: Type or paste the repo address into the Source Path / URL box. Choose where you want to store it locally in the Destination Path box. Click the Clone button.

Step 4: Enjoy your freshly cloned repo with an origin remote already set up for you.

2 Likes

I have found that cloning using the https url works fine but I have not succeeded in getting the ssh url to work. I keep getting the error message “This is not a valid source path / URL”. Under Details it says “FATAL ERROR: Network error. Connection timed out fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.”. I have followed the instructions to create a public / private key installed on the GitLab and SourceTree respectively using a 1024 RSA, 2048 RSA Puttygen key/pair and a openssh key/pair restarting Pageant SSH agent in between to no avail.

Any advantage to using SSH over HTTPS for the cloning? If not I’ll stick with HTTPS as it works fine. Just curious why the SSH option was failing. Thanks in advance to anyone who solves this :slight_smile:

1 Like

SSH is generally faster from what I understand. If it works both directions with HTTPS and you don’t care, stick with it. If you want SSH to work, make sure you have read and/or write access to the repo you’re trying to clone. If it’s just a public project and you aren’t a member of it, HTTPS is probably all you’ll get. If you own the project or are a member of it you should have no issues with the SSH version.

1 Like

Cheers for the help…at some point I’ll sort out why the ssh doesn’t work and post the outcome here for others. I’ll certainly look to your suggestion that the permissions are the issue as my first item to re-check so thanks for that :slight_smile:

1 Like

I was able to clone a repo via https however what about multiple gitlab accounts with sourcetree?

1 Like

Hmm I am using SourceTree 1.6.1 on Win7 against a gitlab 8.0.4 installed on RHEL 6 but the HTTPS fails.

When trying to clone with http SourceTree spews following error

Couldn’t find host git.****.tld in the _netrc file; using defaults …

We have our own CA certs and I configured it correctly in the curl-ca-bundle.crt. Testing this with git 1.9.5 command lines works all fine.

The sourcetree details show that it is opening to port 443 ok then picking up the CAFile fine but then it starts talking about Unknown SSL protocol error in connection to … Closing Connection 0

Did anyone ever experience something like this with SourceTree?

Thanks Niels

1 Like

Answering my own question … turns out the embedded git version 1.9.5 of SourceTree does not work with gitlab and the multiple 302 redirects one is getting when using the https scheme. Selecting a system installed git version (in my case 2.5.0) works as far as I can tell.

2 Likes

Initially when I tried to Fetch from a Gitlab remote in SourceTree, I got error messages like this:

git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin
Access denied
Access denied
Access denied
Access denied

FATAL ERROR: Server sent disconnect message
type 2 (protocol error):
"Too many authentication failures for git"
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Completed with errors, see above.

This was running Source Tree 1.6.something and 1.7.0, with the remote hosted in GitLab Community Edition version 8.1.4.

It turned out my issue was to do with the SSH Client Configuration (the ‘access denied’ and “Too many authentication failures for git” messages were the big clues). I made two changes in Tools > Options which fixed this:

  1. Changed SSH Client to OpenSSH, instead of the default PuTTY/Plink
  2. Set a path to my SSH key file.
    After these two changes, fetching, cloning and pushing to my remotes all work fine.
2 Likes

If you want this, vote for the pluggable service API–it’d let SourceTree support GitLab and any others:

Jira ticket for the Mac version of SourceTree is here: https://jira.atlassian.com/browse/SRCTREE-636

1 Like

The SourceTree ticket is from five years ago, no action since then.
It doesn’t look that this will ever be implemented by Atlassian.
Why support their (more capable) competitors?

1 Like

How to setup Sourcetree with two factor authentification(2FA)?
I’m struggling…
I’ve setup an access token on Gitlab, but don’t know how to use it in Sourcetree

1 Like

I recommend you take a look at the article GitHub vs BitBucket vs GitLab to know, which one is the best

Switching to OpenSSH was incredibly helpful! Thank you so much for posting.

  1. Open SourceTree
  2. Tools > Options
  3. On the General tab change SSH client to Open SSH.
  4. Your SSH key field should auto-populate (if it doesn’t you may need to follow these instructions).

@sepp54 We also just turned on 2FA and I’m having the same issue you did. Were you ever able to find a solution?

@sepp54 @uythoang have you tried putting the token in the password field? I guess it works the same as GitHub https://confluence.atlassian.com/sourcetreekb/two-factor-authentication-2fa-with-github-in-sourcetree-402033499.html.

1 Like

Unfortunately GitLab isn’t listed in hosts that you can configure accounts for.