I have successfully cloned a repository from a GitLab instance. The repository is called main
. (It was named that long before most people started using main
as a branch name. That's probably not terribly relevant, but it's maybe worth mentioning to avoid confusion.)
After a couple days, I wanted any new updates from other team members to be included in my local copy. So I ran the following:
git fetch --all
... and got:
Fetching origin
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 4), reused 0 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (5/5), 556 bytes | 185.00 KiB/s, done.
From git.mycompany.com:core/main
* [new branch] TIC-123_Remove_deprecations -> origin/TIC-123_Remove_deprecations
Fetching main
myfirstname.mylastname@git: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
error: could not fetch main
But here's the interesting thing. Running this succeeds:
git fetch
... giving me this:
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 4), reused 0 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (5/5), 547 bytes | 68.00 KiB/s, done.
From git.mycompany.com:core/main
* [new branch] abc/TIC-101_change_wording_in_translations -> origin/abc/TIC-101_change_wording_in_translations
This is not a public repository: There should either be a failure for both cases or for neither, from what I understand.
I have verified that the key in my ~/.ssh/id_ed25519.pub
file is identical to the key that GitLab shows for my user, and that the key is not expired. (It has a month to go.) I have also verified that the repository still exists, and that I have access to it in GitLab.
Any idea how I can regain access to this repository?
===
EDIT: Running git remote -v
shows the following:
main ssh://git/core/main.git (fetch)
main no-push (push)
origin [email protected]:core/main.git (fetch)
origin [email protected]:core/main.git (push)
You have 2 remotes: main
with fetch URL ssh://git/core/main.git
, push disabled; and origin
with URL [email protected]:core/main.git
for fetching and pushing. git fetch --all
fetches from both remotes and it seems one doesn't have your SSH key. You can check that with git fetch main
.
You have to decide if you need remote main
; if not — remove it with git remote rm main
; if yes — configure SSH key at the remote. Or may be fix the remote (add the login git
): git remote set-url main ssh://git@git/core/main.git