Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git commands failing HttpRequestException

I am running Git version 2.12.1 on Windows Server 2012 R2 running against Microsoft Team Foundation Cloud Service. No matter what Git command I run I keep getting this same error. I have even opened my Firewall entirely to see if that was causing it but to no avail. I have tried Clone, Push, & Pull and they all return this error.

git clone https://myaccount.visualstudio.com/_git/myProject
Cloning into 'myProject'...
fatal: HttpRequestException encountered.
   An error occurred while sending the request.

Unhandled Exception: System.ObjectDisposedException: Cannot access a closed file.
   at System.IO.__Error.FileNotOpen()
   at System.IO.FileStream.Flush(Boolean flushToDisk)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at Microsoft.Alm.Git.Trace.Microsoft.Alm.Git.ITrace.Flush()
   at Microsoft.Alm.Cli.Program.Die(String message)
   at Microsoft.Alm.Cli.Program.Die(Exception exception)
   at Microsoft.Alm.Cli.Program.Main(String[] args)
like image 454
ChiliYago Avatar asked Mar 27 '17 22:03

ChiliYago


People also ask

How do I fix a fatal error on github?

The above error indicates that there is one more commit that was pushed to the same branch, but you don't have that commit on your local machine. To fix this, you can easily run a git pull origin <your-branch> , solve the conflicts if any, and then run git push origin <your-branch> to push your changes as well.

How do I get the latest code from Git in Visual Studio?

Visual Studio uses the Sync view in Team Explorer to fetch changes. Changes downloaded by fetch aren't applied until you Pull or Sync the changes. In Team Explorer, select the Home button and choose Sync. In Synchronization, select Fetch to update the incoming commits list.

What is git Credential Manager?

Git Credential Manager creates and stores credentials to access Git repositories on a host of platforms. We hold in the highest regard the need to keep your credentials and access secure. That's why we always keep your credentials stored using industry standard encryption and storage APIs.


2 Answers

According to this issue on the Git Credential Manager issue tracker and my own experience this morning, a HttpRequestException error with an exception of System.ObjectDisposedException: Cannot access a closed file with a repository that was previously working is likely due to the repository host rolling out TLS 1.2 as a requirement and you using a version of the Git Credential Manager before 1.14.0 (included with Git for Windows v2.16.2).

To solve, update to Git for Windows v2.16.2 or newer.

To address iagowp directly, if this is a repository hosted on Github, they started to force TLS 1.2 as of 19:00 UTC on the 22nd of Feb.

like image 198
G.Bragg Avatar answered Oct 27 '22 15:10

G.Bragg


This is a callstack from the Git Credential-Manager for Windows: see its issue 481.
This is a credential helper which will cache in the Windows Credential Manager store the password associated to an account and remote Git Hosting server URL.

Check the value of git config credential.helper

Normal resolution: upgrade Git (which embeds GCM).

In the off-chance a year-old file-related error is the by-produc of a GitHub SSL configuration change (made yesterday), the maintainer for Git for Windows just tweeted:

If you're having trouble connecting to GitHub from Windows today, please make sure to update to the latest version of Git for Windows.
GitHub changed their SSL configuration.


As a workaround (at least to confirm this is the issue), remove credential.helper from any git config setting file. See git config -l --show-origin to list all of them.

Once removed, any clone, if it needs authentication, should prompt you for credentials. But at least, it would not fail.

Check also if the version of the GCM (Git Credential Manager -- for Windows) is the last one or not.

For that, check what Git version you are using.
Check where is your Git program installed: type in CMD session.

where git

Once you know where Git is installed, you can get to the GCM version embedded in Git:

C:\path\To\git
"./mingw64/libexec/git-core/git-credential-manager.exe" version
Git Credential Manager for Windows version 1.14.0
like image 35
VonC Avatar answered Oct 27 '22 15:10

VonC