Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop git via ssh on windows from resolving the wrong path?

I have a windows 2003 box with an ssh server setup. I have msysgit (git version 1.6.2) installed both locally and on the server.

The server has the following absolute path to my repos:

e:\vc\git\myrepo.git

when a user logs in he/she will be put in the following working directory:

e:\vc\git\

When running the following cmd on my dev machine:

git clone ssh://myuser@myip/myrepo.git testrepo

I get the following error:

fatal: ''/myrepo.git'' does not appear to be a git repository

According to my ssh logs it appears that git is executing this cmd on the server:

'cmd.exe /c git-upload-pack '/myrepo.git''

Executing that command locally (on the server) fails for the same reason. I'm thinking the problem is related to git prefixing the path with a '/'. How do I tell git not to do this? Should this be working?

Note: git-upload-pack is working because I added \gitinstallpath\libexec\git-core to the path. Apparently this is a bug and will be fixed in the future, this was my work around.

like image 769
Dane O'Connor Avatar asked Jul 07 '09 14:07

Dane O'Connor


People also ask

How do you fix fatal could not read from remote repository please make sure you have the correct access rights and the repository exists?

The Git “fatal: Could not read from remote repository” error occurs when there is an issue authenticating with a Git repository. This is common if you have incorrectly set up SSH authentication. To solve this error, make sure your SSH key is in your keychain and you connecting to a repository using the correct URL.

What is Git_ssh?

GIT_SSH , if specified, is a program that is invoked instead of ssh when Git tries to connect to an SSH host. It is invoked like $GIT_SSH [username@]host [-p <port>] <command> .


2 Answers

I resolved this by switching my ssh server from winssh to openssh (via the cygwin layer). I was able to connect fine (as noted above) using winsshd, but winsshd wasn't correctly handling paths prefixed with "/". I could probably get winsshd to work, but switching to cygwin and openssh was faster.

Here's a good blog post to kick start the setup if your in a similar situation:

like image 188
Dane O'Connor Avatar answered Sep 25 '22 19:09

Dane O'Connor


Have you tried the following?

git clone ssh://myuser@myip/myrepo testrepo

Note the removal of ".git" from the end of the SSH path. You only need that suffix at the end if the remote directory name has it.

Also, have you tried any other SSH URL format? To use a relative path, you can try:

git clone ssh://myuser@myip/~/myrepo testrepo

See the git clone man page for details on other URL formats.

like image 37
Tim Henigan Avatar answered Sep 21 '22 19:09

Tim Henigan