You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Git无法识别已存在远程仓库及推送失败问题求助

Troubleshooting Your Git Push Issues on Windows 10

Hey there, let's work through these two Git problems you're hitting—they're common for new users, so don't worry!

1. "Repository Not Found" Error When Pushing to GitHub

Even if you've confirmed the URL is correct, there are a few likely culprits here:

Use a Personal Access Token (PAT) Instead of Password

GitHub stopped accepting account passwords for HTTPS Git operations back in 2021, so your earlier attempt to use USERNAME:PASSWORD@ in the remote URL won't work. Here's how to fix it:

  1. Go to your GitHub Settings → Developer Settings → Personal access tokens → Generate new token.
  2. Give it a name, check the repo permission box (this lets it access your repositories), and click "Generate token". Copy this token immediately—you won't see it again.
  3. Update your remote URL with the PAT:
    git remote rm origin
    git remote add origin https://[MyID]:[YOUR_PAT]@github.com/[MyID]/Sandbox.git
    
    Then try pushing again with git push -u origin master.

Clear Stored Windows Credentials

Windows might be caching old or incorrect GitHub credentials. To reset this:

  1. Open the Windows Credential Manager (search for it in the Start menu).
  2. Go to "Windows Credentials" and delete any entries related to github.com.
  3. Run your push command again—Git will prompt you to enter your username and PAT.

Double-Check Case Sensitivity

GitHub treats repository names as case-sensitive, but Windows doesn't. If your remote repo is named sandbox (all lowercase) but your URL uses Sandbox, that'll trigger a "not found" error. Verify the exact name in your GitHub repo settings.


2. GH007: Push Would Publish a Private Email Address

Since you already have your GitHub noreply email, you're almost there! Here's how to resolve this:

Configure Git to Use the Noreply Email

You can set this up either globally (for all your Git repos) or just for the Sandbox repo:

  • Global config (applies to every repo on your machine):
    git config --global user.email "[8-digit-number]+[MyID]@users.noreply.github.com"
    # Make sure your username matches your GitHub account
    git config --global user.name "Your GitHub Username"
    
  • Repo-specific config (only affects Sandbox):
    Navigate into your Sandbox folder first, then run:
    git config user.email "[8-digit-number]+[MyID]@users.noreply.github.com"
    git config user.name "Your GitHub Username"
    

Fix Existing Commits (Optional)

If your initial commit already used your private email, you can rewrite that commit's email (only do this if no one else has pulled from the remote repo—force-pushing will overwrite remote history):

  1. In your Sandbox repo, run this command (replace placeholders with your actual info):
    git filter-branch --env-filter '
    OLD_EMAIL="your-private-email@example.com"
    CORRECT_NAME="Your GitHub Username"
    CORRECT_EMAIL="[8-digit-number]+[MyID]@users.noreply.github.com"
    if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
    then
        export GIT_COMMITTER_NAME="$CORRECT_NAME"
        export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
    fi
    if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
    then
        export GIT_AUTHOR_NAME="$CORRECT_NAME"
        export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
    fi
    ' --tag-name-filter cat -- --branches --tags
    
  2. Push the corrected history with:
    git push -f origin master
    

After setting up the noreply email, any new commits you make won't expose your private email address.


内容的提问来源于stack exchange,提问作者Henry

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 07:32:56