You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Android Studio无法推送项目至GitHub问题求助

Push Failed to GitHub from Android Studio: SSL Self-Signed Certificate Error

What does this error mean?

The error Push failed: Failed with error: unable to access https://github.com/MY_PROJECT_NAME: SSL certificate problem: self signed certificate in certificate chain pops up when Git tries to establish an HTTPS connection with GitHub, but hits a self-signed certificate in the SSL verification chain. This nearly always stems from a corporate proxy, local VPN, or network security tool that intercepts HTTPS traffic and replaces GitHub's official certificate with its own unrecognized self-signed one. Git doesn't trust these unvetted certificates by default, so it blocks the push to keep your connection secure.

Solutions I've tested (and seen work for other devs)

Here are three solid fixes, ordered from most secure to quick-and-dirty:

  1. Import the self-signed certificate into Git (Recommended)

    • First, grab the certificate from your network tool/proxy:
      • Open Chrome/Firefox, visit https://github.com, click the lock icon in the address bar → "Certificate" → "Details" tab → "Copy to File". Pick the Base64-encoded X.509 (.CER) format and save it somewhere easy to find.
    • Tell Git to trust this certificate:
      • Open Android Studio's Terminal tab, run this command (replace the path with your saved certificate's location):
        git config --global http.sslCAInfo "/absolute/path/to/your/certificate.cer"
        
      • If you only want this fix for the current project, remove the --global flag.
  2. Switch to SSH for GitHub authentication
    This bypasses HTTPS entirely, so SSL certificate issues vanish:

    • Generate an SSH key on your machine (search "generate SSH key for GitHub" for step-by-step if you haven't done this before).
    • Add the public key to your GitHub account under Settings → SSH and GPG keys.
    • In Android Studio, go to File → Settings → Version Control → Git and confirm the SSH executable is set to "Native".
    • Update your project's remote URL: Go to Git → Manage Remotes, edit the existing remote to use the SSH format: git@github.com:YOUR_USERNAME/MY_PROJECT_NAME.git
  3. Temporarily disable SSL verification (Not recommended long-term)
    If you need a quick test fix, you can turn off Git's SSL check. Note this is insecure because it lets Git trust any certificate:

    • Run in Android Studio's Terminal:
      # Applies to all Git projects on your machine
      git config --global http.sslVerify false
      
      # Or only for this specific project
      git config http.sslVerify false
      

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

火山引擎 最新活动