Windows10执行make init-dev时Git Clone SSH报错求助
Let’s break down why this is happening and walk through the fixes:
Root Cause
Your problem boils down to two Windows-specific environment quirks:
- Misinterpreted SSH URL: The URL in your script uses
git@gitlab.com:/goodcommerce/goodcommerce-hydra.git– that extra slash after the colon is unnecessary for GitLab SSH URLs. Whenmakeruns via Windows’ default CMD shell, this:/gets mangled into;c(CMD treats the colon+slash as a command separator combined with your system drive letter), resulting in the invalid hostnamegitlab.com;c. - Shell Mismatch: When you run
git clonedirectly, you’re probably using a POSIX-compatible shell like Git Bash or WSL, which handles Git’s SSH syntax correctly. Butmakeon Windows defaults to CMD, which doesn’t understand POSIX shell logic or Git URL formatting the same way.
Step-by-Step Fixes
1. Correct the Git SSH URL
First, fix the URL in your make init-dev script to use the proper GitLab SSH format (remove the leading slash after the colon):
if [ ! -d "goodcommerce-hydra" ] ; then git clone "git@gitlab.com:goodcommerce/goodcommerce-hydra.git" "goodcommerce-hydra"; cd goodcommerce-hydra && git checkout "master"; fi
2. Force make to Use a POSIX-Compatible Shell
To ensure make uses a shell that handles your script correctly, add this line at the top of your Makefile:
SHELL := $(shell which bash)
If which bash doesn’t resolve (common in some Windows setups), hardcode the path to Git Bash’s executable (adjust the path if your Git installation is in a different location):
SHELL := C:/Program\ Files/Git/bin/bash.exe
Verify the Fix
After making these changes, run make init-dev again – it should clone the repository without the hostname error, matching the behavior when you run the git clone command directly.
内容的提问来源于stack exchange,提问作者andres martinez

