迁移至.NET Core MVC后VS2017及Git命令行出现400错误求助
近日我正在进行大规模的文件/解决方案/项目迁移,将原有ASP.NET MVC项目迁移至.NET Core MVC。昨日刚安装并启用Visual Studio Community 2017,但无论是在该IDE还是Windows命令提示符中执行Git命令,均出现错误。此前我可正常推送提交,当前所有程序(含IDE)均以管理员模式运行,且已登录Team Explorer及在线Git项目。所有与HTTPS Git仓库通信的命令均返回“The requested URL returned error: 400”。
在Windows命令提示符中执行的命令及结果如下:
- git status:显示有两个待提交记录,领先master分支
- git push -u origin master:报错“Fatal: unable to access 'https://mygiturl/': The requested URL returned error: 400”
- git pull:报错“Fatal: unable to access 'https://mygiturl/': The requested URL returned error: 400”
但使用VS2015可正常推送提交,其他方式仍报错,目前未找到问题根源。
Hey there, sorry to hear you're stuck with this frustrating Git 400 error mid-project migration—especially since VS2015 works perfectly! Let's walk through targeted fixes to get VS2017 and Command Prompt back on track:
Here are the most likely culprits and actionable steps to resolve them:
1. Refresh Git Credential Manager (GCM)
VS2017 ships with a newer version of GCM compared to VS2015, which can lead to stale or mismatched authentication credentials.
- Open Command Prompt and run
git credential-manager versionto check your current GCM version. - If it's outdated, update it with this command:
git credential-manager install - Clear cached credentials for your repo to force a fresh login:
git credential-manager erase https://mygiturl/ - Try a
git pullagain—you'll be prompted to re-enter your credentials, which should resolve auth-related 400 errors.
2. Verify Your Remote Repo URL
Sometimes VS2017 can accidentally tweak the remote URL (e.g., extra slashes, typos, or format mismatches).
- Run
git remote -vin Command Prompt to list your current remote URLs. - Compare the
originURL to the one that works in VS2015. If they don't match, update it with:git remote set-url origin https://correct-mygiturl/
3. Test with SSL Verification Disabled (Temporarily)
A mismatched SSL certificate or trust store issue might trigger the 400 error. Let's rule this out:
- Run
git config --global http.sslVerify falseto disable SSL verification temporarily. - Try your
git pushorgit pullagain. If it works, don't leave this setting enabled long-term—instead, add your Git server's certificate to your Windows trust store to fix the root SSL issue.
4. Align VS2017's Git Executable with VS2015
VS2017 might use its own embedded Git instead of the system Git you use in Command Prompt, causing inconsistencies.
- Open VS2017, go to Tools > Options > Source Control > Git Global Settings.
- Check the Git executable path—ensure it points to the same Git installation that VS2015 uses (find this path in VS2015's Options menu under the same section).
- Update the path if needed, restart VS2017, and retry your Git commands.
5. Enable Verbose Logging for Advanced Debugging
If none of the above work, enable Git's verbose logging to pinpoint the exact issue:
- In Command Prompt, run:
GIT_CURL_VERBOSE=1 git push -u origin master - Look for details in the logs—like invalid authentication headers, malformed request data, or server-specific restrictions that VS2017 is hitting but VS2015 isn't.
内容的提问来源于stack exchange,提问作者Kelson Olson

