1

I

git clone -v https://test.example.cc/Taotie/discover.git /Users/Macbook/go/src/test.example.cc/Taotie/discover

It fail.

git clone https://test.example.cc/Taotie/discover.git
Cloning into 'discover'...
fatal: 'git@test.example.ccTaotie/discover.git' 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.

but if I

git clone https://github.com/xormplus/xorm.git

it works.

I don't know why it miss a "/" int the git url .

and if I

git clone git@test.example.cc:Taotie/discover.git

it works,because I have already add my mac rsa_pub into the gitlab and I can always git clone success with this format

 git clone git@test.example.cc:anything/project.

The reason I ask this question it that I use go get and it return error

bogon:Taotie Macbook$   go get test.example.cc/Taotie/discover
# cd .; git clone https://test.example.cc/Taotie/discover.git /Users/Macbook/go/src/test.example.cc/Taotie/discover
Cloning into '/Users/Macbook/go/src/test.example.cc/Taotie/discover'...
fatal: 'git@test.example.ccTaotie/discover.git' 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.
package test.example.cc/Taotie/discover: exit status 128

Finally git config --global url."git@test.example.cc:".insteadOf "https://test.example.cc/" solved my problem~~~

panpanla
  • 43
  • 7
  • What if you do: `cd /Users/Macbook/go/src/test.example.cc/Taotie && git clone https://test.example.cc/Taotie/discover.git discover` ? – Sajib Khan Jan 17 '19 at 09:15
  • 1
    "fatal: 'git@test.example.ccTaotie/discover.git' does not appear to be a git repository" This is a syntax related to cloning with SSH. Could you elaborate more on the commands you wrote? – Oren_C Jan 17 '19 at 09:28
  • @SajibKhan I do as you say ,then I get the same error bogon:Taotie Macbook$ git clone https://test.example.cc/Taotie/discover.git discover Cloning into 'discover'... fatal: 'git@test.example.ccTaotie/discover.git' 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. – panpanla Jan 17 '19 at 10:06
  • Try if this work `git clone https://test.example.cc\/Taotie/discover.git discover` ? – Sajib Khan Jan 17 '19 at 10:24
  • @SajibKhan It fails too. ```bogon:Taotie Macbook$ git clone https://test.example.cc\/Taotie/discover.git discover Cloning into 'discover'... fatal: 'git@test.example.ccTaotie/discover.git' does not appear to be a git repository fatal: Could not read from remote repository.``` – panpanla Jan 17 '19 at 12:28
  • @Oren_C I just ```go get test.example.cc/Taotie/discover``` or ```git clone -v https://test.example.cc/Taotie/discover.git /Users/Macbook/go/src/test.example.cc/Taotie/discover ```under manbookpro - macOS Mojave 10.14.2 - bash,and it fails .What information do you need ? – panpanla Jan 17 '19 at 12:35
  • Possible duplicate of [How can I clone a private GitLab repository?](https://stackoverflow.com/questions/30202642/how-can-i-clone-a-private-gitlab-repository) – Baklap4 Jan 17 '19 at 12:50
  • Try this: `git clone https://test.example.cc%2FTaotie/discover.git discover` – Sajib Khan Jan 17 '19 at 13:00
  • @SajibKhan ```fatal: unable to access 'https://test.example.cc%2FTaotie/discover.git/': Could not resolve host: test.example.cc%2FTaotie``` – panpanla Jan 17 '19 at 13:05
  • Possbile duplicate of https://stackoverflow.com/questions/29707689/how-to-use-golang-with-a-private-gitlab-repo – Baklap4 Jan 17 '19 at 13:09
  • @Baklap4 Bingo. – panpanla Jan 17 '19 at 15:16

1 Answers1

2

As @Oren_C said:

"fatal: 'git@test.example.ccTaotie/discover.git' does not appear to be a git repository" This is a syntax related to cloning with SSH.

You're cloning with SSH that being said and the repo exists, the only option left would be that you didn't add a SSH public key to your git instance.

You can copy it from ~/.ssh/id_rsa.pub

Edit

OP had used a wrongly url. The fix was to use: git@test.example.cc:Taotie/discover.git Note the : between host and repo instead of /

Edit 2

To clone the repo into your given directory use the following command:

git clone git@test.example.cc:Taotie/discover.git /Users/Macbook/go/src/test.example.cc/Taotie/discover

This will clone the repo in the given directory: /Users/Macbook/go/src/test.example.cc/Taotie/discover.

last edit

To clone it with Golang you should add a configuration:

git config --global url."git@test.example.cc:".insteadOf "https://test.example.cc/"

This replaces the generated git url to be formatted correctly in the form of: git@host.tld/name/repo.git

Then just run go get https://test.example.cc/Taotie/discover.git

Community
  • 1
  • 1
Baklap4
  • 3,914
  • 2
  • 29
  • 56
  • I have already add my ~/.ssh/id_rsa.pub into gitlab and git clone git@test.example.cc:Taotie/discover.git always work.Now I am trying to google something about "syntax related to cloning with SSH" ~_~ – panpanla Jan 17 '19 at 12:24
  • Something strange happens if I ```git clone -v https://test.example.cc///////////Taotie/discover.git ``` and the error is the same ```Cloning into 'discover'... fatal: 'git@test.example.ccTaotie/discover.git' 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.``` – panpanla Jan 17 '19 at 12:42
  • instead of using the `https` url can you use the git url? `git@test.example.cc:Taotie/discover.git` note the `:` instead of `/`. Full command should be `git clone git@test.example.cc:Taotie/discover.git` This will clone the repo in your current folder. – Baklap4 Jan 17 '19 at 12:44
  • awesome, Updated the answer with the solution. Feel free to mark it as an answer – Baklap4 Jan 17 '19 at 12:49
  • em......my real problem have not yet been solved,Because as I mention on my question upon ,It is because I want to use go get test.example.cc/Taotie/discover and then go get transfer it into ```cd .; git clone https://test.example.cc/Taotie/discover.git ...``` and it fails at the end.So even I can git clone git@xxx ,but I can't use go get to get private repos.and If I can't use go get ,things that related to lib dependent will make me crazy. – panpanla Jan 17 '19 at 12:54
  • Updated the answer with the cloning into a given directory. – Baklap4 Jan 17 '19 at 12:58
  • Updated answer to support the golang question which wasn't provided upon answering – Baklap4 Jan 17 '19 at 13:14
  • 1
    ```git config --global url."git@test.example.cc:".insteadOf "https://test.example.cc/"``` solved my problem ,thanks. – panpanla Jan 17 '19 at 15:20