Re: Git problem in windows server
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Nov 21, 2024, 14:28 UTC
- Message-ID
- <15918318-8071-4c20-9e83-9b93a5410683@gmail.com>
- In-Reply-To
- <e020539e-b66b-4d4d-80da-9f51d4b66683@tool.es>
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 > >