“Does not appear to be a git repository” when trying to clone via SSH

扶醉桌前 提交于 2021-02-10 13:23:29

问题


I have a Windows 10 machine running that I would like to host a git repo on. OpenSSH is running and I am able to SSH into the machine via Powershell, so it is connectable.

I created a new git on that machine in a folder named Test via

git init --shared --bare

I'm now trying to clone using Sublime Merge with the source URL like so:

ssh://USER@IP:/Test

However, after I put in my password, I get two errors:

fatal: "/Test" does not appear to be a git repository

fatal: Could not read from remote repository

I've tried googling with both issues but have not gotten anything that has helped. Is anyone able to help?

Edit: I can clone, commit, and push locally on the remote machine, so it definitely is a git repo.

Edit #2: FIXED. Followed this guide on how to point directly to a git folder by forcing the repo to use powershell (very bottom) https://github.com/PowerShell/Win32-OpenSSH/wiki/Setting-up-a-Git-server-on-Windows-using-Git-for-Windows-and-Win32_OpenSSH

**Note that git clone user@domain@servermachine:C:/test/myrepo.git does not work due to known issue. Work around it to set powershell as default Shell in registry. Or by following steps when cmd is default shell:

cd c:\mygitrepros
# initialize a local repo folder
git init mylocalrepo
cd mylocalrepo
# add the remote repro
git remote add origin user@domain@servermachine:C:/test/myrepo.git
# work around the known issue by launching powershell to run the git commands
git config --local remote.origin.uploadpack "powershell git-upload-pack"
git config --local remote.origin.receivepack "powershell git-receive-pack"

git fetch origin


回答1:


Here you can find a complete tutorial how to hast a repo.

https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server

That repo is for linux but i think the steps should be similar. When you create a Bare-Repository with:

$ cd /srv/git
$ mkdir project.git
$ cd project.git
$ git init --bare
Initialized empty Git repository in /srv/git/project.git/

It's common to name the folder with .git. But after that you should be able to clone with the following command.

git clone git@gitserver:/srv/git/project.git

So you have add the path to the Git-Folder. I think that is your problem. You try only the path "/Test" from your Root-Directory. That could be wrong and Git tell you that this folder is not a Git-Repository.



来源:https://stackoverflow.com/questions/56673762/does-not-appear-to-be-a-git-repository-when-trying-to-clone-via-ssh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!