Visual Studio 2017推送至GitHub远程仓库失败问题求助
Hey there! Let’s get your local repo pushed to GitHub without leaving Visual Studio 2017 or learning new tools. Here are simple, targeted fixes to try:
Verify Visual Studio’s Git Credential Helper
Open VS 2017, go to Tools > Options, expand Source Control > Git Global Settings. Make sure the Credentials Helper is set to Manager for Windows—this lets Windows handle your GitHub login info correctly. If it’s set to something else, switch it, restart VS, and try pushing again.Double-Check the Remote Repository URL
In Team Explorer, click the gear icon (Settings), select Repository Settings, then go to the Remotes section. Select theoriginremote, click Edit, and confirm the URL is exactlyhttps://github.com/CalebADB/Static-Motion.git. Save the change and retry the push.Confirm GitHub Repository Permissions & Branch Names
Log into your GitHub account in a browser to make sure theStatic-Motionrepo exists and you have push access. Also, check that your local branch name (e.g.,mainormaster) matches the default branch on GitHub—mismatched names can block pushes.Use VS’s Built-in Git Command Prompt
You don’t need Git Bash—VS has its own command line for Git. In Team Explorer, go to Home > Changes, click Actions > Open Command Prompt, then run these commands:git remote set-url origin https://github.com/CalebADB/Static-Motion.git git push -u origin main # Replace "main" with "master" if that's your local branchIf prompted, enter your GitHub credentials. Note: If you have two-factor authentication (2FA) enabled on GitHub, you’ll need to use a Personal Access Token (PAT) instead of your password—you can create one in your GitHub account settings under Developer settings > Personal access tokens.
Reset Windows Credentials for GitHub
Sometimes stored credentials get corrupted. PressWin + R, typecontrol keymgr.dllto open Credential Manager. Under Windows Credentials, find any entries forgithub.com, delete them, then go back to VS and try pushing again. You’ll be prompted to re-enter your credentials, which should fix any stale login issues.
内容的提问来源于stack exchange,提问作者Caleb Barynin

