0

I have a repo at Gitlab, started in W10. I pushed it.

I cloned it into a Linux OS and started doing things. I created a new branch, call it "mybranch". I pushed it. It's there, in Gitlab.

During these various ops in Linux I also established an SSH key so I wouldn't have to constantly enter my user name and password. This might be relevant... NB back in W10 I don't have to enter the user name + pwd either... but I think I set that up some other way than an SSH key.

I've just gone back to W10 and have gone git pull. git branch -a does not show "mybranch".

So I looked at various similar questions:

I first went git fetch --all. After this:

  • git remote update does not solve the problem (shows only "master")

  • git pull --all does not solve the problem, I get:

    "Your configuration specifies to merge with the ref 'refs/heads/master' from the remote, but no such ref was fetched."

  • git remote show origin gives a response I don't understand:

    "fatal: 'origin' does not appear to be a git repository
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights and the repository exists."

Then, trying to follow this, I added the following 2 lines to the "config" file of my local git repo:

[remote]    
    fetch = +refs/heads/*:refs/remotes/origin/*

Then I tried the things above again and got exactly the same answers. git branch -a only ever shows "master".

Possibly I need to edit the "config" file in my Gitlab (remote) repo rather than the local one. But I couldn't find it in Gitlab.

So I'm floundering. Maybe I've configured something badly! I have no idea.

Attempt to clone

Interesting. I find I can't clone either in W10 (i.e. in a fresh directory):

...>git clone git@gitlab.com:mikerodent/myproject.git
Cloning into 'myproject'...
The authenticity of host 'gitlab.com (172.65.251.78)' can't be established.                                             
ED25519 key fingerprint is SHA256:eUX...........
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitlab.com' (ED25519) to the list of known hosts. 
git@gitlab.com: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

Further actions after suggestions by torek
I deleted the two lines in the file "config"
I added a new SSH key to Gitlab using the procedure which worked in Linux
I made the connection between my machine & the remote:

(myproject) D:\My documents\myproject>git remote set-url origin ssh://git@gitlab.com/mikerodent/myproject
error: No such remote 'origin' # failed
(myproject) D:\My documents\myproject>git remote add origin https://gitlab.com/mikerodent/myproject.git
(myproject) D:\My documents\myproject>git remote set-url origin ssh://git@gitlab.com/mikerodent/myproject # no error reported

NB a curious point is that it wouldn't let me choose a normal W10 path to store my SSH key file: in the end I had to choose the default "/home/mrodent/.ssh" (i.e. Linux-style path). I don't know what this means: I'm using a W10 terminal.

Unfortunately this didn't resolve the issue. However the above did seemingly modify the config file (local repo) as required: I now find it is as follows:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[branch "master"]
    remote = https://gitlab.com/mikerodent/myproject.git
    merge = refs/heads/master
[remote "origin"]
    url = ssh://git@gitlab.com/mikerodent/myproject
    fetch = +refs/heads/*:refs/remotes/origin/*

Similar fails to previously:

(myproject) D:\My documents\myproject>git fetch --all
Fetching origin
git@gitlab.com: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
error: Could not fetch origin
(myproject) D:\My documents\myproject>git pull --all
Fetching origin
git@gitlab.com: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
error: Could not fetch origin
(myproject) D:\My documents\myproject>git remote show origin
git@gitlab.com: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
(myproject) D:\My documents\myproject>git remote add origin git@gitlab.com:mikerodent/myproject.git
error: remote origin already exists.
(myproject) D:\My documents\myproject>git branch -a
* master  

I note that it says "could not fetch origin" at the same time as saying "remote origin already exists". It appears this may be a permission problem...

If anyone can recommend where I might read up on the issues which might be involved there that'd be good. I have no idea what's going on.

joanis: Output from git remote -v

(myproject) D:\My documents\myproject>git remote -v
origin  ssh://git@gitlab.com/mikerodent/myproject (fetch)
origin  ssh://git@gitlab.com/mikerodent/myproject (push)

Yes, I can clone using git clone https.... All expected branches are there.

mike rodent
  • 14,126
  • 11
  • 103
  • 157
  • Do you get the same problem on W10 if you try to clone with https instead of ssh? In my setup, I tend to end up with https on W10, with my W10 Credentials Manager managing my passwords, and ssh on Linux, with my ssh-agent and key managing my access rights there. A `git remote -v` on your original W10 sandbox might also be informative. – joanis Jan 28 '22 at 01:33
  • Thanks. See output from that command above. Trying now with https... – mike rodent Jan 28 '22 at 19:12

1 Answers1

0

git remote show origin gives a response I don't understand:

fatal: 'origin' does not appear to be a git repository

This means you don't have a remote named origin. (Why that is, if you ran git clone, is a bit of a mystery, but you don't show your git clone command so we can't really guess.)

I added the following 2 lines to the "config" file of my local git repo:

[remote]    
    fetch = +refs/heads/*:refs/remotes/origin/*

That isn't quite right as the line above fetch should read:

[remote "origin"]

But there's an easier way to get this line, and the other one you also need, added, using git remote add:

git remote add origin git@gitlab.com:mikerodent/myproject.git

(assuming this is the correct URL; it may not be, based on your other errors). Note that you will probably want to remove the bogus [remote]-with-no-name and subsequent fetch line before using git remote add.

git@gitlab.com: Permission denied (publickey,keyboard-interactive).

This generally means you have the wrong ssh keys set up (either the wrong ones stored on gitlab.com, or the wrong one set in your .ssh/config file locally).

torek
  • 448,244
  • 59
  • 642
  • 775
  • Please see additional CLI input. NB I don't know what you mean by "other errors". The only change I have made is to alias my Gitlab account and Gitlab project for the purposes of this question. Also I have now added my (failed) attempt to clone into a fresh directory in W10. The clone in Linux happened days ago, and I don't therefore have the output from that. – mike rodent Jan 28 '22 at 18:50
  • Other errors = other complaints you got from Git when trying to clone. Perhaps i should have said "other error *messages*"? – torek Jan 29 '22 at 04:22
  • BTW I have no idea about Windows 10, but given: *NB a curious point is that it wouldn't let me choose a normal W10 path to store my SSH key file: in the end I had to choose the default "/home/mrodent/.ssh" (i.e. Linux-style path).* - I suspect there's something not set up right with ssh at this point. A useful diagnostic trick here is to use `ssh git@gitlab.com` to run *only* ssh, not using Git at all, so that you can test your ssh setup before you add Git into the mix. – torek Jan 29 '22 at 04:27