6

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!

SebasSBM
  • 860
  • 2
  • 8
  • 32
  • Possible duplicate of [How to change the URI (URL) for a remote Git repository?](https://stackoverflow.com/questions/2432764/how-to-change-the-uri-url-for-a-remote-git-repository) – Brian Jan 23 '19 at 17:14
  • 1
    I think you might be taking the wrong approach here. I recently migrated a git repo from a local filesystem to Bitbucket. BB doesn't have a built-in option to import a repo from a file, either. I ended up needing to switch the remote URL to a "fresh" repo in BB and then do a merge. Worked like a charm :) – Brian Jan 23 '19 at 17:20
  • In my case, almost every step-by-step guide I find is out of context for some reason (I barely can explain it, but it's like everyone of them, when I look carefully at them, I just can yell: that's not my case!). In addition, `git` is not present on the system's `PATH` envvar... so i do a `find -name git` from the unit's root folder and I find several of them spread around... which of them can I rely on? Everything is just too confusing... – SebasSBM Jan 23 '19 at 18:09
  • I managed to find the folder where `GitLab` created the "empty repo" (probably triggered by GitLab's importing form). It's like it puts a folder like `myproject.git` for every single project I try to import. Those folder's contents are suspiciosly similar to any `.git` folder present in any repository made using `git` in a CLI... but there's no working tree at all! – SebasSBM Jan 23 '19 at 18:13
  • @Brian I don't think my question is a duplicate of the one you posted for at least two reasons: 1- I am using GitLab, the OP of the other question isn't. 2- GitLab doesn't add `git` into the `PATH` envvar. I have no other option to do it according to the GitLab's structure. – SebasSBM Jan 24 '19 at 07:11
  • @Brian Indeed, my problem is more similar to the one in [this question](https://stackoverflow.com/questions/48518323/gitlab-repository-does-not-exists-issue) than to the one you referenced as duplicate. – SebasSBM Jan 24 '19 at 07:19
  • I was thinking that the second answer from the link would apply -- I used a similar procedure for the Bitbucket import I mentioned yesterday. Glad you found a solution. – Brian Jan 24 '19 at 20:43

3 Answers3

5

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.

jonashackt
  • 12,022
  • 5
  • 67
  • 124
4

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!

SebasSBM
  • 860
  • 2
  • 8
  • 32
1

In my case, the root cause of this issue was that my password (a temporary HTTP password created by Gerrit) had special characters in it. I had to keep generating passwords until I was given one without special characters.

davidvandebunte
  • 1,286
  • 18
  • 25