117

I am trying to clone a project from gitlab to my local machine. I have been granted rights as a developer, and use the command 'git clone

  • None of the protocols work (ssh and https neither work)

The error message I am getting:

remote: The project you were looking for could not be found.
fatal: repository 'https://gitlab.com/KZA_Connected/skilltree.git/' not found

Any help would be highly appreciated.

flaxel
  • 4,173
  • 4
  • 17
  • 30
tijnster
  • 1,387
  • 3
  • 8
  • 12

24 Answers24

174

I solved this by simply adding username to url like below,

before: https://gitlab.com/gitlab_user/myrepo.git

after: https://gitlabusername@gitlab.com/gitlab_user/myrepo.git

Abdul Karim Khan
  • 4,256
  • 1
  • 26
  • 30
58

Today, I was having the same issue. The repo was working fine at my home machine, but when I tried the same repo in other machine I started facing the same error. I was using below URL

https://gitlab.com/{gitlab_user}/project_repo.git

And now I changed above URL to below

https://{gitlab_user}@gitlab.com/gitlab_user/project_repo.git

And it worked for me. Above solution was found at below URL

https://medium.com/@imstudio/gitlab-the-project-you-were-looking-for-could-not-be-found-issue-685944aa5485

Hope this helps other.

Abdul Waheed
  • 4,540
  • 6
  • 35
  • 58
52

I have two gitlab accounts. For both I use ssh keys. Both are hosted by gitlab (not self-hosted).

When you run

ssh -T git@gitlab.com

It will return your username.

Welcome to GitLab, @username1!

I was using ssh for @username1 and @username2. It defaults to the first ssh found. So, AFAIK, it's impossible to have two accounts with ssh.

My solution was to rm ssh key from the gitlab account I am not using.

Tom Wojcik
  • 5,471
  • 4
  • 32
  • 44
  • 3
    +1 because this might help in the case of a multiple gitlab users conflict, I have read about that elsewhere, and this is likely a good workaround, without having tested it, though. – questionto42 Mar 11 '21 at 21:47
  • 7
    You can set up hostname aliases to use the keys with different accounts, see https://gist.github.com/oanhnn/80a89405ab9023894df7 – Eliot Sep 21 '21 at 20:58
  • 3
    Further to Eliot's comment covering using aliases on GitHub, a similar thing is possible on GitLab. After assigning aliases in the ssh config (`Host USERNAME.gitlab.com`), you can then eg. clone with `git@USERNAME.gitlab.com:REPO_OWNER/REPO.git` See: https://docs.gitlab.com/ee/ssh/ – Mina Jan 13 '22 at 19:41
  • I just added my other gitlab account as a collaborator and it works perfectly fine for me under my circumstances – ansakoy Oct 02 '22 at 11:33
  • 2
    that's great answer that helped me to understand the issue. – Sarvar Nishonboyev Dec 19 '22 at 07:01
30

On mac osx, it usually means that your ssh credentials are not loaded. Brute force solution:

cd ~/.ssh
ssh-add *

I have to do this every time my Macbook reboots.

user3278073
  • 421
  • 4
  • 4
26

Simple Answer: Reset your already existing origin using the following command.

git remote set-url origin https://gitlabUsername@gitlab.com/some-group/project.git

For you it's,

git remote set-url origin https://gitlabUsername@gitlab.com/KZA_Connected/skilltree.git

git remote -v (To check if the changes are reflected), then

git push origin master

Finished.

If it's the first time after the git init

Then

git remote add origin https://gitlabUsername@gitlab.com/gitlabUsername/project_repo.git

Because git remote add origin https://gitlab.com/gitlabUsername/project_repo.git will not work, use the above instead.

If still you get the error, then Remove remote origin by the following and add a new one again

git remote remove origin

Manu R S
  • 872
  • 9
  • 6
  • `git remote set-url origin git@gitlab.com:USERNAME/PROJECTNAME.git` worked to update to SSH push. Thank you! – Ryan Boken Aug 10 '23 at 14:52
20

I solved the above problem

Before: https://gitlab.com/gitlab_user/myrepo.git

After: https://<gitlabusername>@gitlab.com/gitlab_user/myrepo.git

Explanation:

Type your gitlabUsername in place of <gitlabusername>.

Now, it will ask for gitlab password for that your account. Enter the correct password and the project will be cloned successfully.

Ashish Gupta
  • 211
  • 2
  • 4
16

There is credential manager on windows, which contains details about credentials of your host here is s.s of credential manager enter image description here

  1. First of all make sure you have same user credentials which have access to repository which you are trying to clone. If you have correct credentials

then try this url formatter

https://{username}@gitlab.com/username/repo-name.git

in your case it will be like this

'https://username@gitlab.com/KZA_Connected/skilltree.git/'

i was able to solve my problem deleting my credentials and adding them again i hope this help others too

-- Important note this credential manager save your global credentials, you can set your local credentials too using git config

git config --local user.name "Your name"
git config --local user.email "Your email"
git config --local credential.helper "store"

if you set credential.helper to store, in current local git scope it will ask you password every time you do action like pull, push etc

if you want to reset credential.helper, then simply set it back to manager it will work fine as before

Hanzla Habib
  • 3,457
  • 25
  • 25
13

If you (like me) have added multiple ssh keys, the solution is to explicitly state which key should be used for a remote host.

Add the following lines to the ~/.ssh/config file, depending on your use case:

Host bitbucket.org
User git
IdentityFile ~/.ssh/id_rsa

Host gitlab.com
User git
IdentityFile ~/.ssh/id_ed25519
Samuel Olwe
  • 131
  • 1
  • 5
  • I have mulitple ssh keys as well, and this was not enough. For me it was also needed to also run 'ssh-add ~/.ssh/', after which the different keys could be found. – Romano Vacca Sep 05 '21 at 15:03
  • Yes, 'ssh-add' is a given, even for a single ssh key. It tells the authentication agent about your keys. – Samuel Olwe Sep 07 '21 at 22:07
12

If adding the ssh key does not work, follow this -

eval "$(ssh-agent -s)"

Then add the ssh key

ssh-add ~/.ssh/<id_rsa>
Ninad Kulkarni
  • 474
  • 4
  • 7
11

First of all verify your credentials are correct.

git config user.email
git config user.name

If they are correct, try appending your username@ before your repo address.

E.g. Instead of

git clone https://repo.abc.com/projectname.git 

Try

git clone https://username@repo.abc.com/projectname.git
David Buck
  • 3,752
  • 35
  • 31
  • 35
Vishnu Hari
  • 149
  • 1
  • 6
8

If you are facing the issue for a fresh repo

Just simply change the gitlab default https url from https://gitlab.com/rscodelab/project.git to https://rscodelab@gitlab.com/rscodelab/project.git

for example

git clone https://gitlab.com/gitlabusername/project.git

to

git clone https://gitlabusername@gitlab.com/gitlabusername/project.git

Manu R S
  • 872
  • 9
  • 6
6

Put username before the url like this:

git clone https://username@repo.abc.com/projectname.git

To add git to an existing folder accordingly:

git remote add origin https://username@repo.abc.com/projectname.git
skm
  • 559
  • 1
  • 6
  • 22
4

Solution: it was due my windows credentials being set to an other email account.

tijnster
  • 1,387
  • 3
  • 8
  • 12
  • 2
    incase anyone don't know how to change credentials check this answer https://stackoverflow.com/a/63899445/3946527 – Hanzla Habib Oct 02 '20 at 05:25
3

In my case, I was not adding .git at the end of URL.

https://gitlab.com/{gitlab_user}/project_repo

corrected to

https://gitlab.com/{gitlab_user}/project_repo.git

This might seem like a silly mistake, but that was it!

Mehul Pamale
  • 349
  • 3
  • 13
  • 1
    Thanks. That was the problem in my case. The push worked fine from a GUI which, presumably, added the `.git` suffix automatically. It did not work from the command line until I've set the url to the `.git` version though. – MarcinKonowalczyk Mar 12 '21 at 23:37
2

If it's the first time after the git init command, Then use the below command

git remote add origin https://gitlabUsername@gitlab.com/gitlabUsername/project_repo.git

Because git remote add origin https://gitlab.com/gitlabUsername/project_repo.git will not work, use the above instead.

If still you get the error, then Remove remote origin by the following and retry again by adding the origin using the correct command. to remove origin - git remote remove origin

  • "https://gitlabUsername@gitlab.com/gitlabUsername/project_repo.git" didn't work. The only thing that worked for me is "https://gitlabUsername@gitlab.com/group/subgroup/project.git" – m_highlanderish Jan 23 '23 at 13:16
  • Alternatively, with ssh: "git@gitlab.com:group/subgroup/project.git". It's very annoying, because I couldn't find an example anywhere with groups and subgroups, all the examples have username instead of group and that didn't work. – m_highlanderish Jan 23 '23 at 13:27
1

On Intellij go to

Git->Manage Remotes

then select the url and edit your url to be https://{gitlab_user}@gitlab.com/gitlab_user/project_repo.git

Click Ok. On your password request. You can use your gitlab access token as password if you face authentication challenges.

A.Mushate
  • 395
  • 3
  • 7
1

I was frustrated about this error

Following Steps solved the error(Run All this in terminal)

  1. ssh -T git@gitlab.com Output -> Welcome to GitLab, @username!
  • Go to "Git Bash" just like cmd. Right click and "Run as Administrator". Type ssh-keygen
  • Press enter.
  • It will ask you to save the key to the specific directory. Press enter. It will prompt you to type password or enter without password.
  • The public key will be created to the specific directory.
  • Now go to the directory and open .ssh folder.
  • You'll see a file id_rsa.pub. Open it on notepad. Copy all text from it.
  • Go to https://gitlab.com/-/profile/keys or Paste here in the "key" textfield.
  • Now click on the "Title" below. It will automatically get filled. -Then click "Add key".command
  1. Now You Clone the project using

    git clone https://username@gitlab.com/organization_name/project_name.git

0

I honestly don't know how GitLab works, I use GitHub, but check if the repo is marked as private.

I had similar issue on GitHub where my friend couldnt retrieve and clone my repo even though he had a status of "Contributor" cz I accidentaly checked it to be Private. Also check if your GitLab account and one you are using in your Command line tool is matching.

0

if your git --version > 2.10

run the following command in your project repo :

git config --add core.sshCommand "ssh -o IdentitiesOnly=yes -i ~/.ssh/path-to-your-key -F /dev/null"

from this page

joanis
  • 10,635
  • 14
  • 30
  • 40
Xhyl
  • 1
0

I got new account from my company gitlab so I added new ssh key but I got permission issue when tried to clone via ssh.

Then I tried ssh -T git@gitlab.com which returned Welcome to GitLab, @<my_old_account>! I realized I have to remove old ssh keys from .ssh folder. I removed them and it worked.

Sarvar Nishonboyev
  • 12,262
  • 10
  • 69
  • 70
0

I tried the above solutions but none work for me. But they helped me in understanding the problem. I had two Gitlab accounts on my new PC.

1 - Remove the Gitlab account in credential Manager Windows.

2 - No need to change the Url of the project.

3 - If you try to push now it will show another error and shows you a pop-up to sign into GitLab.

4 - If you were to sign up using a username/password. The problem will still persist. It will not work. The solution is to sign in through a Web Browser like chrome/edge. It will work. You will be able to push the project.

Rohaitas Tanoli
  • 624
  • 4
  • 16
0

If you are still facing the issue while cloning then try cloning with personal token

git clone https://<username>:<token>@gitlab.example.com/tanuki/awesome_project.git

For more refer this link.

Kartik Garasia
  • 1,324
  • 1
  • 18
  • 27
0

I resolved this problem by changing my role on gitlab, before my role was a developer and asked to owner change it to maintiner and this problem solved for me

-3
  • Open a spotlight search.
  • Go to Keychain Access.
  • Search for GitLab.
  • Make sure your account(username) and password match the GitLab credentials for the account you're using to clone the repo.