64

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Wagh
  • 2,678
  • 1
  • 25
  • 29
  • If the below answers don't help, maybe you could share the error message you get when you try to submit. – thelr Feb 19 '15 at 14:18
  • I found this article http://jaredleonmorgan.net/2016/03/16/Using-Source-Tree-to-Access-Git-Lab.html – Tom Stickel Mar 02 '17 at 08:33

8 Answers8

68

This worked for me,

Step 1: Click on + New Repository> Clone from URL

Step 2: In Source URL provide URL followed by your user name,

Example:

  • GitLab Repo URL : http://git.zaid-labs.info/zaid/iosapp.git
  • GitLab User Name : zaid.pathan

So final URL should be http://zaid.pathan@git.zaid-labs.info/zaid/iosapp.git

Note: zaid.pathan@ added before git.

Step 3: Enjoy cloning :).

Mohammad Zaid Pathan
  • 16,304
  • 7
  • 99
  • 130
17

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.

IBam
  • 10,114
  • 1
  • 24
  • 36
nick_mn
  • 221
  • 3
  • 9
  • 1
    For me this worked fine. Was a problem with cloning repo but after adding a key to keychain was able to access the repo and all the branches. Thanks! Use command 'ssh-add -K {your_private_key}' to get the passphrase. – SergiiKozlov Sep 16 '15 at 09:06
5

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

Abdurrahman Mubeen Ali
  • 1,331
  • 1
  • 13
  • 19
3

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.

TGU
  • 181
  • 2
  • 7
  • 2
    This actually works. A pitfall is that in the field labeled "password" the token you created on GitLab has to be put. Not the password you normally access GitLab with. – Günther Eberl Feb 06 '19 at 21:54
2

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:

git@gitlab.com:USER/REPOSITORY.git

and your email like:

test@google.com

then this settings should be work:

URL / path: https://test%40google.com@gitlab.com:USER/REPOSITORY.git
Alex
  • 368
  • 2
  • 13
1

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.

sventechie
  • 1,859
  • 1
  • 22
  • 51
0

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.

thelr
  • 1,134
  • 11
  • 30
0

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

q0re
  • 1,401
  • 19
  • 32