threads / discuss / 62523

Git problem in windows server

Subject: Git problem in windows server

## tl;dr

5 messages between Nov 21, 2024 and Nov 22, 2024.

replies: 4people: 4as markdown or json

Luis Heredia· Nov 21, 2024, 10:24 UTC · lore
Good day,
I have a problem that i can not solve after a lot of checks.

In my windows server 2019 i created a bare repository (c:/gitServer/git.git). In that server i create a new directory and I can clone it without any problem. The repository is good.

When I go to my local machine, i can start communication with ssh to the server (cmd ssh ssh://user@serverIp:port). I can navigate to the path of the repository (cd \gitServer\git ) and change anything (copy c:\temp\temp.txt). With this i can be sure that the rights in the server are correct.

The problem is when i try to clone in my windows 10 local machine (cmd git clone - v ssh://user@serverIp:port/gitServer/git.git c:/temp) i always receive the error "fatal: ´´/gitServer/git.git''  does not appear to be a git repository".

In server and local machine the version of git is 2.47.0.windows.2
Can anyone help me ?
Thanks
Luis
Phillip Wood· Nov 21, 2024, 14:28 UTC · re: Luis Heredia · lore

Re: Git problem in windows server

Hi Luis
On 21/11/2024 10:24, Luis Heredia wrote:
Show 18 quoted lines
> Good day,
> 
> I have a problem that i can not solve after a lot of checks.
> 
> In my windows server 2019 i created a bare repository (c:/gitServer/ 
> git.git). In that server i create a new directory and I can clone it 
> without any problem. The repository is good.
> 
> When I go to my local machine, i can start communication with ssh to the 
> server (cmd ssh ssh://user@serverIp:port). I can navigate to the path of 
> the repository (cd \gitServer\git ) and change anything (copy c: 
> \temp\temp.txt). With this i can be sure that the rights in the server 
> are correct.
> 
> The problem is when i try to clone in my windows 10 local machine (cmd 
> git clone - v ssh://user@serverIp:port/gitServer/git.git c:/temp) i 
> always receive the error "fatal: ´´/gitServer/git.git''  does not appear 
> to be a git repository".

I'm not a Windows expert but I think the problem is that git expects the server to run the command passed to it with a posix compatible shell but the default shell on windows is cmd.exe which uses different quoting rules that cause the command line to be mangled. The solution is either to set the shell used by ssh to bash.exe (see [1] for how to do this) or to use the --upload-pack argument to git clone to execute the command with bash by running

     git clone --upload-pack '"c:\Program Files\Git\bin\bash.exe" -c 
"git upload-pack \"$@\"" git-upload-pack' 
ssh://my.server/c:/gitServer/git.git

(Note I'm assuming that you're typing this in bash, if you're using cmd.exe you'll need to alter the quoting)

If you clone using --upload-pack you'll need to set remote.origin.uploadpack and remote.origin.receivepack to run the appropriate commands when you push and pull

     git config remote.origin.uploadpack '"c:\Program 
Files\Git\bin\bash.exe" -c "git upload-pack \"$@\"'
     git config remote.origin.receivepack '"c:\Program 
Files\Git\bin\bash.exe" -c "git receive-pack \"$@\"'
Best Wishes
Phillip

[1] https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh-server-configuration#configuring-the-default-shell-for-openssh-in-windows

Show 9 quoted lines
> In server and local machine the version of git is 2.47.0.windows.2
> 
> Can anyone help me ?
> 
> Thanks
> 
> Luis
> 
> 
Konstantin Khomoutov· Nov 21, 2024, 19:05 UTC · re: Luis Heredia · lore

Re: Git problem in windows server

On Thu, Nov 21, 2024 at 11:24:42AM +0100, Luis Heredia wrote:
[...]
> The problem is when i try to clone in my windows 10 local machine (cmd git
> clone - v ssh://user@serverIp:port/gitServer/git.git c:/temp) i always
> receive the error "fatal: ´´/gitServer/git.git''  does not appear to be a
> git repository".
Does it work if you call
  git clone ssh://user@serverIp:port/c/gitServer/git.git
or may be
  git clone ssh://user@serverIp:port/c:/gitServer/git.git
?

Basically the problem appears to be in that the Git process spawned remotely in the SSH session set up by your local Git process, is given the path component of the repository URL, which is "/gitServer/git.git" in your case. Obviously, this path is not correct on Windows filesystems.

rsbecker@nexbridge.com· Nov 21, 2024, 19:28 UTC · re: Konstantin Khomoutov · lore

RE: Git problem in windows server

On November 21, 2024 2:05 PM, Konstantin Khomoutov wrote:
Show 19 quoted lines
>On Thu, Nov 21, 2024 at 11:24:42AM +0100, Luis Heredia wrote:
>
>[...]
>> The problem is when i try to clone in my windows 10 local machine (cmd
>> git clone - v ssh://user@serverIp:port/gitServer/git.git c:/temp) i
>> always receive the error "fatal: ´´/gitServer/git.git''  does not
>> appear to be a git repository".
>
>Does it work if you call
>
>  git clone ssh://user@serverIp:port/c/gitServer/git.git
>
>or may be
>
>  git clone ssh://user@serverIp:port/c:/gitServer/git.git
>
>?
>
>Basically the problem appears to be in that the Git process spawned
remotely in the
>SSH session set up by your local Git process, is given the path component
of the
>repository URL, which is "/gitServer/git.git" in your case.
>Obviously, this path is not correct on Windows filesystems.

Some SSH servers restrict interactions to a specific directory rather than allowing access to the root of the disk. I got around that by setting up a link (via Cygwin64) to the target location, which bypasses the configured SSH root. It would then require a different URI to account for that.

--Randall

← back to recent threads