Retrieving corrupted Git Repository in TFS 2015

Deepak Kumar Mishra, Support Engineer, EMEA TFS Team, brings this knowledge experience while working with one of his customers and this important piece of information might help a lot of users who are using Git repos in tfs and face with data corruption in Git repositories.

Issue Description:

Following a Windows Server unexpected shutdown, there was a problem accessing a specific TFS Git repository xxxx (all other repositories worked fine). The symptoms are:

While accessing the problematic repository xxxx, users are being asked for credentials each time (entering the credentials has no effect) & the following errors are encountered

VS Studio output:

Error encountered while cloning the remote repository: Response status code does not indicate success: 401 (Unauthorized).


Web portal:

TF401037: The Git index file contains invalid data.

Troubleshooting and resolution:

1. We checked and found that there was a clone for the repository xxxx available with one of the users. We tried to create a new Git repository in TFS web access and pushed the available clone to the server but found that we did not have all the ranches and code of xxxx. The git repository  QC-Connectors got corrupted due to automatic shutdown of the tfs server in the weekend

2.Then we checked and found that we had a tfs test server and also backup of tfs databases from the time the unexpected shutdown occurred. Then we restored the databases in test environment and performed a tfs cloning in the test environment. The cloning operation was successful and we were able to browse the Git repository xxxx successfully without any errors.

3.We did a bare clone of the xxxx git repository from the test tfs environment:


4. After the bare clone is successful, we change directory to xxxx.git from where we can do the push operation to the tfs server


5. Finally we did a Git mirror Push to the production tfs environment by first renaming the old existing corrupt repository to xxxx_corrupt and then create a new Git repo xxxx from the web access:


6. After successful push operation, we were able to successfully browse through all data in xxxx repository without any errors and this issue was resolved. We also removed the renamed git   repository xxxx_corrupt at the end.

Written by: Deepak Kumar Mishra

Reviewed by: Nitish Nagpal, Support Escalation Engineer

Comments (1)

  1. Brad says:

    What were the conditions that caused this repo to become corrupted was someone cloning or checking in while the TFS server was restarted? I would like to know what procedures one could do to mitigate this risk? Would shutting down TFS via quiesce be the answer here before you rebooted the TFS server?

Skip to main content