如何修复在使用 git 克隆时“找不到你要找的项目”

我正试图从 gitlab 克隆一个项目到我的本地机器上。我已被授予作为一个开发人员的权利,并使用命令‘ git 克隆

  • 这些协议都不能工作(ssh 和 https 都不能工作)

我得到的错误消息是:

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

如果你能帮忙,我将不胜感激。

208274 次浏览

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.

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

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.

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

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.

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

eval "$(ssh-agent -s)"

Then add the ssh key

ssh-add ~/.ssh/<id_rsa>

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

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!

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.

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

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

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

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

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.

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

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

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

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

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.