Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Gitlab fails importing repository from local network with status code 128?

I have recently installed GitLab with Docker in a server within a local network. I am trying to migrate a repository I mantained locally in my PC. I exposed it through a local HTTP server within my local network as a workaround, just to be able to import it to GitLab, because almost all options available in GitLab admin Panel are like "Import from GitHub", and none of those options will help in my case (I mean: couldn't I just upload my repository's .git folder to import it? -retorically speaking) By the way, the one I chose was "Repo by URL":

enter image description here

There's a security setting that I had to disable, because GitLab doesn't allow importing from URLs that point towards a server in your local network. So I turned on the option called "Allow requests to the local network from hooks and services" within the Outbound Services section.

Then, I tried making a new project from GitLab, using the tab called "import project" and filling the form within it. Then, it keeps running for a long while with the message "Importing..." looks like it keeps retrying over and over, until this message is shown:

Every import attempt has failed: Error importing repository http://111.222.33.44/path/to/my/repository/root/folder/.git into myuser/my_project - 13:CreateRepositoryFromURL: clone cmd wait: exit status 128. Please try again.

I have been reading the Gitlab Manual posted online, different articles about GitLab, googled about this error and found tens of tickets with similar (but very different!) issues... But I still don't understand: why can't I just upload my repository right away?

The URL given is not the problem per se: if I type it into a web browser, I can see clearly the entire filesystem of my project within the web browser, and, if I add /.git to it, I can even see the hidden .git folder's content in my browser... but, for some reason, this isn't enough for GitLab...

I am very confused about this. One of the links I found is Export a repository from a Gitlab server to another Gitlab server (Please notice I am mot importing from other Gitlab, but a simple git repository created in a PC with a simple git init. Finding reading material about something remotely similar to my case isn't a piece of cake: I have been searching about this the whole day, without success...). Within that link, there is a part that says:

You will get warnings that you cloned an empty repository. This is normal. Change into the working directory of your checked out repository and do a git pull

...so I found the folder where my GitLab installation created the "empty repository", and tried executing the git pull command from there, giving it the route to my other local server machine. Something similar to this:

git pull http://111.222.33.44/path/to/my/repository/root/folder/my_project.bundle

...just after succeeding making a .bundle file on the other side, following the instructions I found in the above link. But, for some reason, my GitLab server's CLI doesn't find the command git! (Perhaps is is wrapped on some kind of virtualenv? Or rather it wasn't included in PATH in the first place? Who knows...). In any case, pull to where? There's no working directory to pull from!

Is there something else I could do about this? My knowledge about Git is limited: I have almost always used it to mantain repositories on my own, all alone, without the need to push them anywhere, neither pull them from anywhere (with the rare exception of one GitHub project of mine).

I might add that the official Gitlab's manual about howto import projects includes instructions to migrate from everywhere, except the original, unwrapped, unsugared, normal git command-line software!

like image 480
SebasSBM Avatar asked Jan 23 '19 15:01

SebasSBM


2 Answers

I had the same error Error importing repository http://111.222.33.44/path/to/my/repository/root/folder/.git into myuser/my_project - 13:CreateRepositoryFromURL: clone cmd wait: exit status 128. Please try again..

In my case I had to provide a username and password, since the repository I imported from was secured with that (gitblit). I tried also many ways, but in the end it seems to be a GitLab glitch. For me using the provided fields Username (optional) and Password (optional) didn't work! I had to provide the credentials directly inside the Git repository URL field (as the old screenshot in the docs also suggest):

gitlab import page

With that the import worked like a charm - and at great speed.

like image 122
jonashackt Avatar answered Oct 02 '22 11:10

jonashackt


In the end, the true problem was a misunderstanding with how GitLab's web menu works, actually.

When you click "New Project" in GitLab's web interface, there are 3 tabs to pick from:

  • Blank Project
  • Create from template
  • Import Project

I wasn't thinking that "Blank project" would be the way to go... I mean... "I am trying to import my project into GitLab" was my idea, so I waS TRYING FROM "Import Project" tab (and that's why I ended up posting this question)... but, trying from "Blank Project" solved my issue.

I was just giving up my commit history and trying to make a new repository from scratch, from my current's project files' state. But, unexpectedly, after creating the "blank project", GitLab gave me instructions to import my repository into this "blank project". I quote:

CMD Instructions - Existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin http://gitlab.somedomain.net/myuser/someblank-domain.git
git push -u origin --all
git push -u origin --tags

And thus, a "blank project" became an "imported project". Problem solved!

like image 42
SebasSBM Avatar answered Oct 02 '22 10:10

SebasSBM