10

While trying to clone an already existing repository from gitlab into my local drive. I used the format

$ git clone https://github.com/libgit2/libgit2  mylibgit 

The resulting folder e.g mylibgit was found somewhere outside the XAMPP web folder (i.e htdocs), I moved it there but it's not working as supposed.

I moved it out to my desktop and got the error :

fatal: unable to access 'https://git@gitlab.com:xxxxx/yyyyyy/':Port number ended with 'y'
Seunara
  • 157
  • 1
  • 1
  • 9

5 Answers5

10

For gitlab, you don't need to specify the user.
Replace it by an https url based on your GitLab account name.

cd /path/to/your/repo
git remote set-url origin https://gitlab.com/<username>/<yourProjectName.git>
git push -u origin master

Note:

trying to clone an already existing repository from gitla

This contradict "git clone https://github.com/libgit2/libgit2", since this is a GitHub url, not a GitLab one.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @Madeo What does `git remote -v` return? You would see '`origin`' if you have cloned a repository. But for a new local repository, you would need to add a remote. – VonC May 13 '20 at 14:08
  • @Madeo `cd /path/to/local/new/repo; git remote add oprigin https://gitlab.com//`: make sure `/` on GitLab is anew empty repository (no README, no nothing) – VonC May 13 '20 at 14:19
  • @Madeo I would need to see the URL used to understand. There is no port number involved. – VonC May 13 '20 at 15:09
  • @Madeo `git remote add` works perfectly in an initialized repo, with HTTPS or SSH URLs. You simply used an incorrect URL triggering that "Port number" error message. – VonC May 14 '20 at 05:27
  • @Madeo I did not express an opinion when stating "`git remote add works perfectly in an initialized repo, with HTTPS or SSH URLs`. I was stating a fact, a practice seen many times over the years, including in official documentations: https://help.github.com/en/github/importing-your-projects-to-github/adding-an-existing-project-to-github-using-the-command-line – VonC May 14 '20 at 12:57
  • @Madeo So I would be genuinely interested to know what URL did you use which could possibly trigger `Port number ended with 'c'` – VonC May 14 '20 at 12:58
  • 1
    Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/213863/discussion-between-vonc-and-madeo). – VonC May 14 '20 at 13:43
4

Gitlab actually requires a user when using deploy tokens. For me, this was caused by mixing in ssh syntax as http://<user>:<pass>@gitlab.com:repo instead of gitlab.com/repo.

thisismydesign
  • 21,553
  • 9
  • 123
  • 126
2

if you change your remote from using ssh to https and accidentally leave a colon in the string - you will a message like this. It's a confusing message, but it makes sense once you understand the source of the problem.

Cyrus
  • 583
  • 6
  • 9
0

I later found the problem, I was not typing cd /path/to/your/repo at the beginning.

I was actually typing gitlab instead of Github.

Thanks.

Mostafa Norzade
  • 1,578
  • 5
  • 24
  • 40
Seunara
  • 157
  • 1
  • 1
  • 9
0

I had similar problem. Just corrected(removed git@ and port number) URL in .git/config file and it worked.

[remote "origin"] url = https://git@gitlab.com:xxxxx/yyyyyy/

To

[remote "origin"] url = https://gitlab.com/yyyyyy/

Narendra Kothule
  • 1,064
  • 9
  • 7