Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Visual Studio push over HTTPS fails: Git failed with a fatal error

ErrorError encountered while pushing to the remote repository: Git failed with a fatal error.

Short answer

Visual Studio hides the real message. Run the same git push in a terminal to read it. When it is a certificate error, your Git does not trust the CA that signed the server, often a company or self-hosted GitLab CA. Point http.sslCAInfo at that CA file, and pick the SSL backend that matches where it is trusted.

  • Applies to Git 2.50, Git for Windows, Visual Studio 2022
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Push from a terminal in the same repository. The message there names the real problem, and tells you which cause below applies.

    git push origin main
  2. 2Match what you see, then jump to its fix

    1. 1The terminal reports a certificate verification failure for a self-hosted or company server.Git does not know the certificate authority that signed the serverFix
    2. 2Browsers open the server without warnings, but Git rejects it.Git uses the OpenSSL backend while the CA is installed in the Windows storeFix
    3. 3http.sslCAInfo is set, the backend is schannel, and the same error remains.The backend is schannel, so the CA file you set is ignoredFix

What does the error look like?

  • Error encountered while pushing to the remote repository: Git failed with a fatal error.
  • Git failed with a fatal error (the Visual Studio message hides the real cause)

Cause 1 of 3

Git does not know the certificate authority that signed the server

1Check

http.sslCAInfo names the file with the certificates Git uses to verify the server when fetching or pushing over HTTPS. See whether it is set, and where.

git config --show-origin --get-all http.sslCAInfo

2Fix

Get the CA certificate (PEM) from your administrator and tell Git to use it for that server only.

git config --global http."https://gitlab.example.com/".sslCAInfo "C:/certs/company-ca.pem"

3Verify

Push again from the terminal and then from Visual Studio.

git push origin main

Confirmed by git-scm.com

Did this fix it?

Cause 2 of 3

Git uses the OpenSSL backend while the CA is installed in the Windows store

1Check

http.sslBackend selects the SSL library, openssl or schannel. Secure Channel uses the Windows certificate store, where your company CA is usually installed.

git config --show-origin --get http.sslBackend

2Fix

Switch Git to the Secure Channel backend.

git config --global http.sslBackend schannel

3Verify

Push again.

git push origin main

Confirmed by git-scm.com

Did this fix it?

Cause 3 of 3

The backend is schannel, so the CA file you set is ignored

1Check

With schannel, Git tells curl not to use the http.sslCAInfo bundle by default, because it would override the Windows store.

git config --show-origin --get http.schannelUseSSLCAInfo

2Fix

Either import the CA into the Windows Trusted Root store and keep schannel, or switch to the openssl backend, or set http.schannelUseSSLCAInfo to true.

git config --global http.schannelUseSSLCAInfo true

3Verify

Push again from a terminal.

git push origin main

Confirmed by git-scm.com

Did this fix it?

How do I stop it coming back?

  • Scope the CA file to one server with http.<url>.sslCAInfo, so the setting does not affect other hosts.
  • Do not turn off verification (http.sslVerify, or GIT_SSL_NO_VERIFY) to make a push pass; it stops Git from checking the server certificate.
  • Keep the CA file in a fixed path that is documented for the team.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.