tijnster
tijnster

Reputation: 1667

How to fix 'The project you were looking for could not be found' when using git clone

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

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.

Upvotes: 145

Views: 374947

Answers (25)

Abdul Karim Khan
Abdul Karim Khan

Reputation: 4945

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

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

After: https://[email protected]/gitlab_user/myrepo.git

Upvotes: 212

Abdullah Esnawi
Abdullah Esnawi

Reputation: 79

1- Check the current remote URL

git remote -v

If it is incorrect, add the correct URL

git remote add origin [email protected]:<username>/<repository>.git

For example:

git remote add origin [email protected]:KZA_Connected/skilltree.git

2- If the problem is still not resolved, reset your email and username for the current repository directory

username

git config user.name "Your name Here"

email

git config user.email "[email protected]"

Upvotes: 1

ecstrema
ecstrema

Reputation: 691

Branch have only conditionally the right to reference commits in other gitlab projects.

We had to add an exception to reference commits from the particular other project.

Upvotes: 0

Asror Abdukadirov
Asror Abdukadirov

Reputation: 11

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

Upvotes: 1

Kartik Garasia
Kartik Garasia

Reputation: 1454

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.

Upvotes: 3

SAHIL SHARMA
SAHIL SHARMA

Reputation: 41

I was frustrated about this error

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

  1. ssh -T [email protected] 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://[email protected]/organization_name/project_name.git

Upvotes: 3

Rohaitas Tanoli
Rohaitas Tanoli

Reputation: 807

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.

Upvotes: 0

Sarvar Nishonboyev
Sarvar Nishonboyev

Reputation: 13110

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 [email protected] 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.

Upvotes: 1

A.Mushate
A.Mushate

Reputation: 455

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.

Upvotes: 1

Xhyl
Xhyl

Reputation: 1

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

Upvotes: 0

skm
skm

Reputation: 609

Put username before the url like this:

git clone https://[email protected]/projectname.git

To add git to an existing folder accordingly:

git remote add origin https://[email protected]/projectname.git

Upvotes: 7

Samuel Olwe
Samuel Olwe

Reputation: 191

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

Upvotes: 19

Vishnu Hari
Vishnu Hari

Reputation: 169

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://[email protected]/projectname.git

Upvotes: 13

Tom Wojcik
Tom Wojcik

Reputation: 6189

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

When you run

ssh -T [email protected]

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.

Upvotes: 65

Manu R S
Manu R S

Reputation: 970

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://[email protected]/rscodelab/project.git

for example

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

to

git clone https://[email protected]/gitlabusername/project.git

Upvotes: 9

Mohamed Sanaany
Mohamed Sanaany

Reputation: 11

  • 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.

Upvotes: -2

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

git remote add origin https://[email protected]/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

Upvotes: 2

Hanzla Habib
Hanzla Habib

Reputation: 3723

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://[email protected]/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

Upvotes: 17

Ashish Gupta
Ashish Gupta

Reputation: 271

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.

Upvotes: 22

Mehul Pamale
Mehul Pamale

Reputation: 406

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!

Upvotes: 3

Manu R S
Manu R S

Reputation: 970

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

git remote set-url origin https://[email protected]/some-group/project.git

For you it's,

git remote set-url origin https://[email protected]/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://[email protected]/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

Upvotes: 35

Ninad Kulkarni
Ninad Kulkarni

Reputation: 476

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

eval "$(ssh-agent -s)"

Then add the ssh key

ssh-add ~/.ssh/<id_rsa>

Upvotes: 12

user3278073
user3278073

Reputation: 501

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.

Upvotes: 37

Abdul Waheed
Abdul Waheed

Reputation: 4678

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.

Upvotes: 66

tijnster
tijnster

Reputation: 1667

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

Upvotes: 4

Related Questions