Git 将代码推送到分支时出现 TypeInitializationException

Git TypeInitializationException while pushing code to branch

我正在尝试将代码推送到我的远程分支。我收到以下错误日志。

Unhandled Exception: System.TypeInitializationException: The type
initializer for 'Microsoft.Alm.Cli.Program' threw an exception.
--->
System.Runtime.InteropServices.SEHException: External component has
thrown an exception.    
  at AzureDevOps.Authentication.TokenScope.op_BitwiseOr(TokenScope left, TokenScope right)    
  at Microsoft.Alm.Cli.Program..cctor()    
  --- End of inner exception stack trace ---    
at Microsoft.Alm.Cli.Program.Main(String[] args) 
  fatal: Authentication failed for
'https://dev.azure.com/ubplDevOps/ConnectrixCompanyAndroidApp/_git/ConnectrixCompanyAndroidApp/'

当我发送推送命令时,会弹出一个密码弹出窗口,但当我输入密码时,会出现上述错误。我可以使用相同的密码在网络上登录我的帐户,但它不允许我推送 .

检查在克隆 Azure 存储库时是否看到选项 "Generate Git Credentials",如

同时检查所使用的遥控器 URL:

git config --get remote.<azure-remote-name>.url
# or simply
git remote -v

# check the URL referring to azure

如果其中包含项目帐户,请将 URL 替换为您的 Azure 用户名(登录 Azure 帐户时使用的用户名)。


I was working on the same repository for around 2 months. Yesterday it started giving this error.

没有recent Azure incidents,所以尝试更改您的密码,看看重置是否对您当前的问题有影响


OP Vivek Mishra points to personal access tokens,在 OP 的情况下已经过期。

Azure has some personal access token, that was expired for my user.
I regenerated that token and added and it started working

那是 introduced in 2018,并且包含到期日期。