How start use SourceTree with GitLab?
Asked by Francisk Rae:

Good day, dear community members.  
I ask for your help. Who can explain to me, step by step, all the steps for installing SourceTree and configuring it for use with GitLab? At the same time, GitLab is on a "dedicated server".  
Please do not mock answers with links to articles in the instructions section, I have already read them all and they did not help me, they are all broken just like SourceTree itself.

I have been fond of game development for a long time and always dreamed of working in it, and now I get my first vacancy in game development, I start work on Monday and before Monday I have to prepare all the tools, this morning in three hours I installed and configured more than a dozen necessary for my work of programs and utilities, professional and no less complex than SourceTree, while I have known half of them for a long time, I have never worked with half, but I did not have any problems with any, and now it came to SourceTree, the first time I tried to install the built-in git at the installation stage, errors popped up saying that the file could not be copied because it was used by another program, after searching a little, I just added SourceTree and all related folders to the antivirus exceptions, and turned it off during the installation it, and ran the installation as an administrator and this problem was gone. But then the following arose, described here many times over the course of a year by different users, and I have the same problem:

<https://community.atlassian.com/t5/Sourcetree-questions/Remote-repository-no-longer-accessible/qaq-p/1892481?tempId=eyJvaWRjX2NvbnNlbnRfbGFuZ3VhZ2VfdmVyc2lvbiI6IjIuMCIsIm9pZGNfY29uc2VudF9ncmFudGVkX2F0IjoxNjQ1MjA4MTc3MjY0fQ%3D%3D#U1949459>

From which I conclude that if such a significant problem is not fixed for more than a year, then the tool is abandoned, the outdated instructions also speak about this, even here on the official website. In general, it's a strange thing, I rarely see this, but there is no adequate and up-to-date information on such a popular tool on the Internet and even on YouTube, all text articles about installation and configuration are copied from three or four fairly old five-year-old instructions describing the already outdated state of the interface and functionality tool. All videos on YouTube are either "water" (not informative) or do not exhaustively cover the issue, since they do not show the whole process from beginning to end, but look like a piece taken out of context. As a result, after 3 hours I installed everything I needed, I took up SourceTree and it's been 15 hours since I started SourceTree, but there is still no result. And it would seem that you could just take and use another git GUI , but despite the fact that it is abandoned, it still remains perhaps if not the best then almost the best of the free options, judging by the video, I obviously see that its functionality (if it turned out to make it work) undoubtedly increases productivity both in comparison with other GUIs for git, and in comparison with the console version, and even more so. It would seem that you can take and use a paid tool, with which there will be no such problems, but here's the thing, I'm a trainee, and so far I can't afford to buy all the desired tools. Yes, and my colleagues use it with success, but the fact is that I am the only person in the whole team who works in the Windows OS, all the rest on MAC or Linux, so they can't really tell me what the problem is ... Well, again, taking into account I asked one colleague that I was an intern - he said that he couldn't tell how it was under Windows, but I wouldn't really want to work with the console version either and I don't want to strain with my noob problem, but everything needs to be prepared before Monday.

And so, I install SourceTree, go through all the installation steps, and I don't understand why I need to enter a bitbucket account at the beginning of the installation if I don't plan to work with the repository on bitbucket? Then, having gone through the installation steps already without any errors, I get into the program window, and a cross in a red circle is displayed on my avatar, as in that error from the link above, and this leads to the fact that my data is deleted from the program after exiting, and next time when I start the program, I again see the installation steps and again I have to enter my bitbucket account, as I imagine this is not at all user friendly, and this is simply an inadequate program device. In all professional and even simple programs, when starting the program, even if something else needs to be configured, what we usually see: an empty program window until we open a file or project, or a welcome window with a suggestion to open a file or project, which is most often possible disable in the settings so that it is customary to see an empty program window and the program menu and everything, occasionally in fairly old or complex programs, if the program is not yet configured, we can see the setup wizard, which is easy to close and does not block the main functionality of the program and allows you to configure everything as usual through the settings menu. And here, every time I start the program, I see an inadequate program installation window by launching an already installed program from a shortcut on the desktop. As I understand it, if I can set it up in one go so that everything works, then the installation process will no longer be displayed at startup. But no matter what I tried to do, I tried to set it up for my bitbucket account first, and created a test repository on bitbucket, and created an ssh key, and inserted it where necessary, and tried all possible options in the settings - the error does not disappear and with each A new input starts the installation process of the already installed program. And now I have a login and a password from a private / dedicated gitlab server. (It's like there is a bitbucket and there is a bitbucket server, on gitlab, as I understand it, the same thing, that is, the domain of our gitlab server is not on gitlab.com , but all emails and notifications, etc. They all come with a mention of gitlab, and the whole interface of the site is like that of gitlab , and colleagues talk about it - gitlab, and accordingly the login and password given to me are registered to my email for work, they are not suitable for gitlab.com login, but only on our server.)

I can log in through a browser, I have access to the repository, I uploaded the ssh key there and generated Personal access tokens, and it's just not so difficult to guess in 2022 where to enter the login and password ;) But no matter how I tried, taking into account the fact that we have our own dedicated server, to which I remind you: half of my colleagues connect via SourceTree, but they have a Mac, and there are no problems that I have on the Win version of the client. And what I just didn't try, there in the options for connecting to gitlab, there are three different "hosting services" related to gitlab, the first in the name of which is simply "gitlab" without additional letters, and with a fixed URL gitlab.com in the line "Host URL" - obviously for connecting to the standard gitlab.com server, the other two options are similar to what I need ... And that's what I tried to do, and the domain of our server indicated, and a link to the repository, both via HTTPS and SSH, and with a personal token and with ssh key, and each time it says that authentication failed. But I can log in through the site, and my colleagues somehow log in through SourceTree, although from a Mac, which means it's possible, but how? If I have already gone through all the possible settings and spent 15 hours on it, and now I have spent an hour writing this message ...

I'm not a git expert, this was my first time with git, before I always did everything alone and there was no need to master git, but in general for most git specialists this is not something super important, many skills are much more difficult and develop over the years, but Now the circumstances are such that I cannot devote as much time as I like to understanding on my own why such a fairly simple tool is so difficult to make work. Just due to the fact that I have never worked with it and want to start with the GUI right away, and at the same time I am limited in time, I cannot understand what is the reason that SourceTree does not work? I don't know how it was when it worked. It should be. To understand where is my mistake and where is the program error.

I almost forgot to add, after each reinstall of sourcetree, I cleared all its directories in the appdata.

Oh, and the last addition: I think everyone who reads it understands that to give their data (login and password, and even tell the hosting address) in order to help me, I can't, since the repository is not public, but private. But if there is someone who wants to help, from those who know how it should work on Windows, under all the above conditions (SourceTree + gitlab server), then I can at least replace my real login and passwords with fictitious ones for clarity, try to explain the sequence of my actions or perform your recommended course of action.


Answers:
author: Francisk Rae
body: It's a miracle I was able to win.  
Apparently it was necessary to sleep and look with fresh eyes.

I will try to talk about every problem that I met on my way (but the journey is not over yet, questions will still arise).

First problem:  
The very first time I tried to install sourcetree , I had errors similar to these:  
<https://community.atlassian.com/t5/Sourcetree-questions/SourceTree-Install-Fails/qaq-p/655282>  
<https://community.atlassian.com/t5/Sourcetree-questions/SourceTree-failed-to-start/qaq-p/642445>  
Notice how old these bugs are and they happen to a lot of users and these bugs still happen. In the current version of the program.  
But I quickly found a solution by giving the installer admin rights and disabling the antivirus. Unfortunately, I won't throw off the error logs, since before each new attempt I cleared all folders, after uninstalling the program through the control panel. ( AppData\\Local\\Atlassian , AppData\\Local\\SourceTree , AppData\\Roaming\\Atlassian )

Second problem:  
When I run the installer, I see the installation steps window - which is normal.  
As I understood from several videos on YouTube, so that the next time I launch the program from the program shortcut, I don't see this window - I have to enter my bitbucket account details. Even if I don't use sourcetree with bitbucket - I don't understand why?  
But after the installation steps are completed, when I see the program window, I see a cross in a red circle on my profile picture, and when I hover over it, I see the error text, as described in this topic:  
<https://community.atlassian.com/t5/Sourcetree-questions/Remote-repository-no-longer-accessible/qaq-p/1892481>  
The problem of more than a year, it is not solved.  
Constantly pressing the refresh button is not a solution.  
I have found that editing the accounts.json and user.config files can solve this problem.  
But I think that this is also not a solution when the necessary edits can be included immediately in the installer distribution.  
Understanding dozens of configs scattered throughout the system, when the program is essentially a graphic add-on (with its own settings) over a console program (with its own settings) - for a beginner in this particular program, it is not so easy. It's not user friendly.  
By the way, a small offtopic: Developers of tools that do not use the appdata as the location of the root folder of the program, but use program files , or make it possible to choose the installation path, as well as making programs that store all their configs in one place, but better in general in the program folder - having lived long happy life, and after life, becomes holy archangels.

Third problem:  
It prevented me from effectively interacting with the program at the stage of installation and setup, and I did not understand how to get around it if the above methods did not help.  
Every time I launched the program from a desktop shortcut, I saw the installation window instead of the program's main interface. And I had to go through these steps again to get to the program interface and try to configure it through the usual program settings window.

But after sleeping, I decided to try the method that I found on the Internet and which I mentioned in the paragraph above - manually edit the config files, and for this I decided to examine the files of the program folders, and found that all this time the problem was "fake" the link in the shortcut to the executable file... I deliberately put the word "fake" in quotation marks so that you understand that this is not a hoax in its purest form, but an unexpected turn for me.  
The actual executable file of the program is located at:  
AppData\\Local\\SourceTree\\app-3.4.7\\SourceTree.exe  
And if you run it after installation, then I get what I wanted - access to the main interface of the program and the ability to configure it through the usual settings window, which has all the functions that we see in the settings wizard on the first run, which is broken.  
While the program shortcut that appears after installation does not lead to the program, but to its launcher:  
AppData\\Local\\SourceTree\\SourceTree.exe  
Which is almost three times smaller in weight than the executable file of the program, so it's definitely a launcher.  
Yes, I understand that many modern programs have a launcher, according to the Update.exe lying next to it, I understand that launching through the launcher is necessary to automatically check for updates before launching the program's executable file.  
But the design of the setup wizard (broken at the same time), visually like the installation process, and placing its functions in the launcher, which is forced to be used if the program is not yet configured, and it does not look like the usual setup wizard, with a window frame and a title at the top of the frame what it is setup wizard, and a cross in the right corner to close the setup wizard and go to manual setup. Why is it so arranged, why is it forced to start? And in the end, taking into account the fact that it is broken, and new users cannot configure the program through it when they first log in, so that the setup wizard would no longer be called. As a result, when a newbie enters the program, he sees not the setup wizard, but the installation window (it looks like this) and does not understand what he is doing wrong. Until I discovered this, I could not understand what was the matter, in my wrong actions or in the first two problems of the program.  
Once I figured out how can I access the main program window bypassing the broken setup wizard by running the executable from: AppData\\Local\\SourceTree\\app-3.4.7  
My attempts are much faster.

Fourth problem (minor):

I saw a block with similar problems on this page on the right, I started reading them, and there I found the answer I needed:  
<https://community.atlassian.com/t5/Sourcetree-questions/Can-t-login-with-my-Gitlab-account-on-SourceTree/qaq-p/1007054>  
when connecting to the gitlab server via HTTPS using a personal token, the personal token must be entered in the password field, which again is not entirely obvious to me as a beginner, I entered my password as through a browser, and I'm not the only one. (looking ahead, I'll say that I noticed that there is a hint about this in the login and password entry window, but apparently yesterday I was already so tired that I didn't notice this, why couldn't it be right in the password field where "password" is written in gray background font - write " personal token"? I looked in the input field and saw that I need to enter a password there and not a token!)  
But the problem itself is that when I realized that I needed to enter a token instead of a password, I entered the program directly, as I wrote above, opened the settings window, realized that I needed to select the gitlab CE service, enter the domain of our server,  
click on the "Refresh Personal Access Token" button to enter the login and token, I entered the login, and first switched to the browser, and then I remembered that the token was no longer visible in the browser and I had to open the text file in which I saved it, I opened the file , copied the token, returned to the SourceTree settings window, and then a problem arose ... the login and password entry window went into the background, under all program windows. I tried to click again on the "Refresh Personal Access Token" button, but again I saw this error "Authentication failed", closing the account settings window, and the main settings window - does not close the login and password entry window. I closed the settings windows and tried to repeat the settings again, but it did not help because the login and password entry window was still open but was behind the main program window, and I did not know this. And only when I closed the main window of the program did I catch a glimpse that the login and password entry window was still open but in the background. After that, restarting the program, and doing everything correctly in one step, I was finally able to set it up and connect to the gitlab server, I saw the remote repository, which is what I have been trying to achieve all this time.  
I think it is necessary to do so that the login and password entry window does not go into the background.

In conclusion, I want to say: I see that many problems are solvable, and how to solve them in the community is suggested, but I don't understand why these problems have not been thoroughly fixed for so long, releasing updates that fix these problems once and for all, for everyone.  
As I said in the first message, despite the problem of getting started with the program, I understand that the program, if not the best of all existing programs for working with git, is definitely the best of the free programs.  
But all these seemingly minor flaws do not interfere with an experienced developer who has been working with git and sourcetree for a long time, all these problems create almost insurmountable obstacles for a novice user of the program.  
Make it possible to skip the setup wizard, and let it look familiar, in the form of a window that is displayed on top of the main program window but smaller than the main one, and with the title that this is a setup wizard, so that users understand that it can be closed.

<br />

Now the problem I faced is my ignorance of which credential helper to choose when cloning the repository from the server to my computer, but this is already a matter of my not knowing git and this is already being solved by reading the information, and the main setup is finished, then I think I can figure it out and colleagues can help me.


author: Nic Brough -Adaptavist-
body: Welcome to the Atlassian Community!

It is very hard for people to work with a huge "wall of text" and I suspect a lot of people will start to read your question and give up because it's too hard to read. I am one of these people. I do not have the time to read an essay and pick out the two or three sentences that define the problem.

I would like to ask you to describe just the \*first\* problem that you have, and give us the basics of what you have set up and tried.

For example, I use Gitlab sometimes, and

* I have Sourcetree on my Mac
* I have asked Sourcetree to connect to the Gitlab projects I'm working with
* I followed the docs on connecting with an SSL key
* It's working fine for me

Could you explain where you are stuck? In a couple of sentences like "Sourcetree runs ok, but when I ask it to connect to Gitlab, it gives me the error 'x...y...z...'"

comments: author: Francisk Rae
body: Good day, well, I'll try in the theses:  
I have a PC with windows 10  
I have a sourcetree , which, on every launch, deletes the bitbucket account I entered, and starts the installation process of the already installed one (itself - sourcetree). The behavior of the program looks inadequate, and does not correspond to what I can see in the reviews on YouTube.  
I need to set up sourcetree work in conjunction with a private gitlab server, which is located on a private server, with a domain like: git.domainname.asia  
However, I know for certain that it is possible to do this in sourcetree on Mac, since several of my colleagues can work with such a server through sourcetree but on Mac.  
I have access to a repository on a private server, I have a username and password, I have a personal token, I have an ssh key, but all my attempts to set up sourcetree ended in failure.

I could not find any instructions in any language of the world, in the form of text or video, describing the complete setup from start to finish, step by step, to start using sourcetree in conjunction with a private gitlab server.  
Let me remind you what I wrote in the first message: all available information is either incomplete or outdated, even here, on the official website.


author: Nic Brough -Adaptavist-
body: Ok, that sounds very broken, but I don't understand what you are doing, or why, right at the beginning.

You say:

\> I have a sourcetree , which, on every launch, deletes the bitbucket account I entered, and starts the installation process of the already installed one (itself - sourcetree).

This sounds like you have downloaded the Sourcetree installer and run it, telling it to install on your machine, told it about a Bitbucket account and let it finish the install. All fine there.

Then it sounds like you are running the installer again, rather than the installed Sourcetree. Of course, that's going to ask you for setup details and install over the top of the one you already installed.

Also, I don't understand what you mean by "deleted the bitbucket account". You can't do that from Sourcetree, you have to go to your Bitbucket account settings on the Bitbucket site to do that.


author: Francisk Rae
body: Thank you for your willingness to help, I was able to find a solution to all of the above problems.


Tags: atl-gruland

gitlab