topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday December 3, 2024, 12:36 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Resolved(?): How to connect to GitLab using SourceTree?  (Read 7141 times)

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,774
    • View Profile
    • Read more about this member.
    • Donate to Member
Resolved(?): How to connect to GitLab using SourceTree?
« on: April 13, 2021, 01:16 AM »
This may be a little niche, or too specific to my situation, but I'm having some troubles and figured I'd ask if anyone here had experience or insight on how to resolve them. No worries if this is too specific. I don't expect anyone here to go through the trouble of setting up GitLab and SourceTree just to help me out, though I wouldn't put it past some of you people to be that awesomely helpful. ;)

A Brief-ish History:
Ten years ago a thread started here on some relatively new distributed version control systems called Git and Mercurial (Hg). At the time when I researched them, I wanted to use Git but it wasn't easy to get working on Windows, so I ended up using Hg. So for about the past ten years I've become an old fart, set in my ways, thumbing my nose at Git while more or less happily using Hg with BitBucket and TortoiseHg. That is, until last year when BitBucket dropped support for Hg repositories. :(

For a little while I remained stubborn and hosted my own RhodeCode server but it wasn't ideal because I actually collaborate with at least one other person on a somewhat regular basis and my ISP's upload speed isn't that great and my internet connection kept dropping out frequently, so it wasn't very reliable for others to connect to and use.

As a result, this past December I decided to bite the bullet and convert all my repositories to Git and start using Git from then on. And after doing some research I decided I'd rather be using GitLab than GitHub. So I first used a feature of GitHub to import my Mercurial repositories from my personal RhodeCode server and convert them to Git automatically. Then I used a feature of GitLab to import my GitHub repositories to GitLab.

While I was still using Hg, I was alternating between using TortoiseHg and SourceTree to manage my repositories. That is, I primarily used TortoiseHg, but I felt SourceTree had better integrated using development branches more easily. When I made the move to Git, I obviously had to drop TortoiseHg, but I decided to just keep using SourceTree, which supports both Git and Hg (for now... Atlassian owns BitBucket and SourceTree).

I think I got it all configured and had it working in December so that I could connect with GitLab and push/pull to/from my repositories. But then this year I've kind of taken a break from my usual thing and have just been doing little experiments that I never felt were big or important enough for version control. But now I'm starting to get back into wanting version control and I've run into a problem where I can't seem to get SourceTree to work with GitLab anymore.

The Problem:
Somehow I was able to successfully create a new remote repository from SourceTree, but then I immediately got an error when it tried to push my local repo to it. The error looks something like this:

remote: HTTP Basic: Access denied
remote: You must use a personal access token with 'read_repository' or 'write_repository' scope for Git over HTTP.
remote: You can generate one at https://gitlab.com/-/profile/personal_access_tokens
fatal: Authentication failed for 'https://gitlab.com/Deozaan/MyCoolRepository.git/'

GitLab has something called "personal access tokens" (PAT) which can be used in place of your password to authenticate third-party apps to work with your account. The UI doesn't make it very clear (IMO) which scopes are needed, and which scopes include the privileges of other scopes, etc. So, while the PAT I created from December had only the "api" scope, the error message says I need "read_repository" and/or "write_repository" so I created a new PAT with all the scopes.

All the things.png

It didn't help. I still get the same error.

I tried changing the URL to use SSH instead of HTTPS, but then it just asks me to load a ppk file which supposedly contains my SSH key. I don't have one of those. Or at least not the right one. I found one on my PC which I thought might be the right one, but when I load it, it just asks me for the SSH password over and over again. So it seems that the password I have stored in my password manager for GitLab SSH key does not match whatever SSH key is in that ppk file.

I do have my SSH private key stored in my password manager, but the putty agent (pageant) which SourceTree uses seems to require PPK format instead of... whatever format I have it stored as. It starts with "-----BEGIN OPENSSH PRIVATE KEY-----" whereas the random PPK file I found where I thought my GitLab SSH key would be starts with "PuTTY-User-Key-File-2: ssh-rsa"

GitLab PATs.pngResolved(?): How to connect to GitLab using SourceTree?

So here I am with two PATs that don't seem to work anymore. Somehow I have saved an incompatible SSH key/password in my password manager. I swear I had this all working fine in December and I don't know what changed in the interim. And I don't know if it's a classic case of PEBCAK, or if GitLab's PATs aren't working right, or if SourceTree is not working properly. I just want to be able to push to and pull from my GitLab repos from SourceTree!

That said, I'm mostly just sticking with SourceTree because I'm already familiar with it and because it's free. If there's an alternative (and free) Git GUI client that works well with GitLab and runs on Windows which would solve my problem, I'd be happy to hear your recommendations on that front, as well. :Thmbsup:
« Last Edit: April 14, 2021, 12:33 AM by Deozaan »

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,939
    • View Profile
    • Donate to Member
Re: How to connect to GitLab using SourceTree?
« Reply #1 on: April 13, 2021, 08:18 AM »
Have been using GitExtensions (free/open source) and Fork (paid) successfully with a remote hosted GitLab (enterprise version) for the last 2 years. There is a need to connect with a VPN client to their VPN server first (2FA only), before I can access their GitLab instance. Hence I expect not much of the safety features in GitLab are activated, the VPN barrier is the security.

The above might be an idea for you too, with regards to securing your GitLab instance.

Back to clients, GitExtensions is pretty stable en pretty extensive. However it misses one very important feature. If you do a diff between files, it won't let you do this side by side, just one view where all changes are shown where they happen. Who ever thought that is sufficient or even efficient, has never worked with side by side diff views. But the creators behind GitExtensions are adamant that a side by side diff are not necessary. And they mention: you can link your favorite diff software to do side by side diffs, so GitExtensions opens it for every file that has a change in it. All nice and dandy, if you have small sets of files that contain changes. But that is not the case where I work. Using that method with a few 100 files and you'll know what a hassle this is.

Fork does side by side diffs natively. It also used to be free, but 6 months or so ago they changed their policy and my boss paid up immediately. I have been playing a little bit with: Guitar  which is a free Git client that does side by side diffs, but there does not seem to be editing capabilities within that view. It has other things going for it, though more time is needed to play with it.

A bit of a rant about Atlassian:
Atlassian is a company with an attitude. We use their Jira product. For legal matters we can only use it as an on-premise product. While they first sent out a communication that the Jira on-premise product would still be supported in the future, their most recent communication now simply states that in 2024 all support drops and that there is only the cloud version of Jira available. Although Internet has improved a lot in Paraguay, it still isn't as stable as it should be. So, even if there were no legal bounds (with financial consequences) to consider, cloud solutions are not just as ideal as a solution as an on-premise server is to me.

But this forced move by Atlassian creates more problems than it is worth. So, their stance on other products like SourceTree can also change on a dime. While it is their right to do so, for my particular use-case they screw me over. Ah well, at least they give enough warning, so there is time to look for alternatives.

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,629
    • View Profile
    • Donate to Member
Re: How to connect to GitLab using SourceTree?
« Reply #2 on: April 13, 2021, 01:21 PM »
Not sure what kind of tooling/IDE you use for development, but I've been very content using VSCode with the Gitlens plugin. Admittedly, I'm 'only' using it with Github (and TFS/AzureDevOps-Git at work), but Gitlab sounds no more than natural to also being supported.

When you're using the Visual Studio IDE, there is the official Gitlab extension available in the marketplace, adding full Gitlab support to VS20xx.

As a direct alternative to SourceTree, Gitkraken is, AFAICS, free for open source Github and Gitlab repo's, so that could also be an option.

And then there's the 'Classic' TortoiseGIT extension for Windows Explorer, quite similar to TortoiseHg and TortoiseSVN.

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,190
    • View Profile
    • Donate to Member
Re: How to connect to GitLab using SourceTree?
« Reply #3 on: April 13, 2021, 02:42 PM »
I use sourcetree and Pageant so I know your pain about the format of the ppk. I'm not sure since you don't know your password, but you can try to regen with PuttyGen from your openssh key and put in the same password you think you used before to see if that helps you connect via SSH.

https://www.simplifi...nvert-ssh-key-to-ppk

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,774
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: How to connect to GitLab using SourceTree?
« Reply #4 on: April 13, 2021, 09:43 PM »
It seems that SourceTree was having a temporary brainfart. I realized I had the GitHub Desktop app installed, so I tried it and I was able to use the same PAT I'm using with SourceTree to communicate with my GitLab repositories. After I saw it was working in GitHub Desktop I tried it again in SourceTree and it still didn't work. That was yesterday, but today SourceTree is working for me again. Weird.

A bit of a rant about Atlassian:
Atlassian is a company with an attitude. We use their Jira product. For legal matters we can only use it as an on-premise product. While they first sent out a communication that the Jira on-premise product would still be supported in the future, their most recent communication now simply states that in 2024 all support drops and that there is only the cloud version of Jira available. Although Internet has improved a lot in Paraguay, it still isn't as stable as it should be. So, even if there were no legal bounds (with financial consequences) to consider, cloud solutions are not just as ideal as a solution as an on-premise server is to me.

That's why I didn't go back to BitBucket even after converting my repositories to Git. I'm ready to migrate away from Atlassian. I'm just using SourceTree for now because I need something now and that's what I know. But I'll be happy to learn/use a new tool.

Similarly with Trello. It just keeps getting worse and worse since Atlassian bought them out. Part of the reason why I made my own To-do List app recently was because I keep fantasizing about making my ideal Trello replacement. At that point I'll be completely rid of all Atlassian products. :Thmbsup:

Not sure what kind of tooling/IDE you use for development, but I've been very content using VSCode with the Gitlens plugin. Admittedly, I'm 'only' using it with Github (and TFS/AzureDevOps-Git at work), but Gitlab sounds no more than natural to also being supported.

When you're using the Visual Studio IDE, there is the official Gitlab extension available in the marketplace, adding full Gitlab support to VS20xx.

I used to be a big fan of Sublime Text several years ago, and I see VSCode as feeling pretty similar to it, but for some reason I haven't been able to "get into" using VSCode on anything.


As a direct alternative to SourceTree, Gitkraken is, AFAICS, free for open source Github and Gitlab repo's, so that could also be an option.

I've attempted to use Gitkraken in the past. It seems nice but I very rarely make my repositories open source or public, and I refuse to pay a subscription. If I could just pay $50-100 for it one time and then be able to use it forever, it might be worth it if it is good enough.

And then there's the 'Classic' TortoiseGIT extension for Windows Explorer, quite similar to TortoiseHg and TortoiseSVN.

Hmm... Yeah, I guess I'll have to give TortoiseGit a try, since I have years of experience with TortoiseHg.

I use sourcetree and Pageant so I know your pain about the format of the ppk. I'm not sure since you don't know your password, but you can try to regen with PuttyGen from your openssh key and put in the same password you think you used before to see if that helps you connect via SSH.

https://www.simplifi...nvert-ssh-key-to-ppk

Thanks for that! I've got the key converted to PPK format with PuTTYGen. The password worked. :Thmbsup:
« Last Edit: April 14, 2021, 12:33 AM by Deozaan »

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,939
    • View Profile
    • Donate to Member
Re: Resolved(?): How to connect to GitLab using SourceTree?
« Reply #5 on: April 14, 2021, 01:45 AM »
The Fork Git client is 49 USD if I remember correctly. My boss is the user who deals with both CVS (his favorite versioning system) and Git, the favorite of the main architect in the company receiving the code we produce. And he found this to be a very reasonable price for Fork. To date it is also a one-time fee. If this changes in the future? My crystal ball is too fogged up to see, I'm afraid.

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,774
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Resolved(?): How to connect to GitLab using SourceTree?
« Reply #6 on: April 14, 2021, 02:15 AM »
I installed TortoiseGit. It appears to only be a shell extension which adds some context menus to Windows Explorer. I was expecting a GUI like TortoiseHg's Workbench. :down:

TortoiseHg Workbench Example.pngResolved(?): How to connect to GitLab using SourceTree?

After that I tried spending a bit more time with GitHub Desktop now that I realize it can work with GitLab. It seems pretty adequate for the job. Though it appears to be a very bare bones git client that is missing some features, such as the option to stash changes for later.

The Fork Git client is 49 USD if I remember correctly. My boss is the user who deals with both CVS (his favorite versioning system) and Git, the favorite of the main architect in the company receiving the code we produce. And he found this to be a very reasonable price for Fork. To date it is also a one-time fee. If this changes in the future? My crystal ball is too fogged up to see, I'm afraid.

Briefly checking out Fork's free evaluation and it actually looks pretty nice. It seems I had downloaded the installer last October in my search for GUI Git clients, but never installed it for some reason. Anyway, after playing around with it for about 10 minutes I'm really impressed by it. I'm still pretty new to Git, so I'm not aware of all the differences in features or workflow compared to Hg, but Fork appears to have all the features and support the workflows I'm familiar with.

I can't find any information on their website or within the program itself as to how long the free evaluation lasts or what limitations it has, other than "you can download and evaluate the Software for free, but need to purchase a license for long-term use." But I'm already thinking it may be worth the $50 asking price. It definitely feels a lot better than SourceTree, which is just getting more and more bloated and convoluted over the years.

It's a shame there's not a version for Linux, which I do occasionally (though very rarely) do some development on. Even so, I'm looking forward to working with it more and seeing if I remain impressed with it as time goes on. Thanks very much for the recommendation! :Thmbsup:
« Last Edit: April 14, 2021, 02:25 AM by Deozaan »

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,939
    • View Profile
    • Donate to Member
Re: Resolved(?): How to connect to GitLab using SourceTree?
« Reply #7 on: April 14, 2021, 02:58 AM »
Here is a nice overview from available Git Clients and for which operating systems these are available.

After a period Fork won't start anymore.


wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,190
    • View Profile
    • Donate to Member
Re: Resolved(?): How to connect to GitLab using SourceTree?
« Reply #8 on: April 14, 2021, 09:42 AM »
I formerly used SourceTree and still do occasionally, but for the most part, I just use VS Code or Git Extensions. I've been wanting to take a look at Sublime Merge- just haven't taken the time yet. I'll add Fork to that list.

As far as Bitbucket vs Github vs Gitlab - I don't trust any of them totally, so use all of them equally, in addition to having a server on my own NAS.