[gitlab] How to integrate sourcetree for gitlab

I worked on github and integrated it to sourcetree (MAC version) for one of my project. I would like to use sourcetree for GITLAB. But I am not able to add remote of gitlab to source tree. In Repository settings, Only I can see host type as "unknown", "bitbucket", "github" & "stash". I used unknown but it won't help me.

Sourcetree Version 2.0.4 (2.0.4)

enter image description here

This question is related to gitlab atlassian-sourcetree

The answer is


Using the SSH URL from GitLab:

Step 1: Generate an SSH Key with default values from GitLab.

GitLab provides the commands to generate it. Just copy them, edit the email, and paste it in the terminal. Using the default values is important. Else SourceTree will not be able to access the SSH key without additional configuration.

STEP 2: Add the SSH key to your keychain using the command ssh-add -K.

Open the terminal and paste the above command in it. This will add the key to your keychain.

STEP 3: Restart SourceTree and clone remote repo using URL.

Restarting SourceTree is needed so that SourceTree picks the new key.

enter image description here

STEP 4: Copy the SSH URL provided by GitLab.

enter image description here

STEP 5: Paste the SSH URL into the Source URL field of SourceTree.

enter image description here

These steps were successfully performed on Mac OS 10.13.2 using SourceTree 2.7.1.

enter image description hereenter image description here


There does not seem to be a way to set up a GitLab account within SourceTree, but if you just clone a remote repo it will use your SSH key correctly.

Edit: After SourceTree 3.0 it is possible to add various non-Atlassian git accounts, including GitLab.


Sourcetree 3.x has an option to accept gitLab. See here. I now use Sourcetree 3.0.15. In Settings, put your remote gitLab host and url, etc. If your existing git client version is not supported any more, the easiest way is perhaps to use Sourcetree embedded Git by Tools->Options->Git, in Git Version near the bottom, choose Embedded. A download may happen.


It worked for me, but only with https link in repository setting (Repository => Repository Settings). You need to change setting to:

URL / path: https://**********.com/username/project.git
Host Type - Stash
Host Root URL - your root URL to GitLab (example:https://**********.com/) 
Username - leave blank

or in some cases if you have ssh url like:

[email protected]:USER/REPOSITORY.git

and your email like:

[email protected]

then this settings should be work:

URL / path: https://test%[email protected]:USER/REPOSITORY.git

It worked for me, but only with ssh key and not with username and password.

After i added the ssh key to sourcetree, i changed the settings under Tools -> Options -> SSH-Client to work with PuTTY/Plink.

I run into trouble after i added the ssh key, because i forgot to restart sourceTree. "this is necessary so that there is an instance of ssh-agent running that SourceTree can talk to with your key loaded." See here: https://answers.atlassian.com/questions/189412/sourcetree-with-gitlab-ssh-not-working


I ended up using GitKraken . I've installed, auth and connected to my repo in 30 seconds.


If you have the generated SSH key for your project from GitLab you can add it to your keychain in OS X via terminal.

ssh-add -K <ssh_generated_key_file.txt>

Once executed you will be asked for the passphrase that you entered when creating the SSH key.

Once the SSH key is in the keychain you can paste the URL from GitLab into Sourcetree like you normally would to clone the project.


Those are optional settings. Leave it set as Unknown and you should be good.

Edit: If "unknown" is no longer an option, try leaving everything in that section blank.