git 致命:与远程交互时遇到 NullReferenceException

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53150690/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 13:14:07  来源:igfitidea点击:

fatal: NullReferenceException encountered when interacting with remote

gitbitbucket

提问by Piotr Perak

This is new machine with fresh install of Git.

这是全新安装 Git 的新机器。

> git --version
git version 2.19.1.windows.1

I cloned repo using https. Every time when I try to talk to remote I get this.

我使用 https 克隆了 repo。每次当我尝试与遥控器交谈时,我都会得到这个。

> git pull
fatal: NullReferenceException encountered.
Object reference not set to an instance of an object.
fatal: NullReferenceException encountered.
Object reference not set to an instance of an object.

I tried uninstalling and installing git again. I also cloned same repo to different directory on disk but none of this helped.

我再次尝试卸载并安装 git。我还将相同的 repo 克隆到磁盘上的不同目录,但这都没有帮助。

When I go to web UI of my BitBucket, there is 2FA enabled. I don't know if this has anything to do with my problem.

当我转到 BitBucket 的 Web UI 时,启用了 2FA。我不知道这是否与我的问题有关。

回答by Lasse V. Karlsen

The reason for this is that the Git Credential Manager (GCM) that is distributed with Git 2.19.1 needs to be updated.

这样做的原因是需要更新与 Git 2.19.1 一起分发的 Git Credential Manager (GCM)。

The release of Git 2.19.1says:

Git 2.19.1的发布说:

Comes with Git Credential Manager v1.18.0.

附带 Git 凭证管理器 v1.18.0。

And when we look at GCM 1.18.1(the next version) release notes:

当我们查看GCM 1.18.1(下一个版本)发行说明时:

Fixes Null Reference exceptions when parameters or contentType are not populated

修复了未填充参数或 contentType 时的空引用异常

(Edit 23. Nov 2018): As @pgsandstromsays in the comment, Git has released a new version that also contains a newer GCM. You can download it here: Git Releases.

(2018 年 11 月 23 日编辑):正如@pgsandstrom在评论中所说,Git 发布了一个新版本,其中还包含一个更新的 GCM。你可以在这里下载:Git Releases



(Rest is old version before 23. Nov 2018))

(其余为2018年11月23日之前的旧版本)

The interim fix, until Git releases a new version with the updated GCM is to simply install the new version of Git Credential Manager yourself.

在 Git 发布带有更新的 GCM 的新版本之前,临时修复是您自己安装新版本的 Git Credential Manager。

So go download the latest version from hereand install it and it should fix your issues.

因此,请从此处下载最新版本并安装它,它应该可以解决您的问题。



Note that it is not clear to me whether this is a fault introduced by Git (ie. it fails to populate the parameter or contentType), or that it is a fault introduced by GCM. All I know is that Git has not released a new version that fixes the issue but GCM has.

请注意,我不清楚这是 Git 引入的错误(即无法填充参数或 contentType),还是 GCM 引入的错误。我所知道的是 Git 还没有发布解决这个问题的新版本,但 GCM 已经发布了。

回答by mpro

I'm running the newest git version 2.19.1.windows.1installed via Scoop.

我正在运行git version 2.19.1.windows.1通过Scoop.

We have migrated repository from GitLab to BitBucket, then I've got the same message:

我们已将存储库从 GitLab 迁移到 BitBucket,然后我收到了相同的消息:

fatal: NullReferenceException encountered. Object reference not set to an instance of an object.

致命:遇到 NullReferenceException。你调用的对象是空的。

What solved the problem was this command:

解决问题的是这个命令:

git config --global credential.helper wincred

回答by Ram Anand Vutukuru

One of the reasons for this could be password changes for git(and other similar version control systems).

原因之一可能是 git(和其他类似的版本控制系统)的密码更改。

I can recommend a couple of solutions

我可以推荐几个解决方案

  1. As mentioned by @mpro, you will be asking to use the credentials stored on the windows credential manager. You would like to update your password accordingly there.

    The way you can reach that point is(in WIN 10): Start -> Control Panel -> Control Panel -> Credential Manager

  2. On the contrary you can ask git to use credentials from its cache by using the following command

    git config --global credential.helper cache

    By doing this, git will prompt for the username and password at each interaction with the remote origin.

  1. 正如@mpro 所提到的,您将要求使用存储在 Windows 凭据管理器中的凭据。您想在那里相应地更新您的密码。

    您可以达到该点的方式是(在 WIN 10 中):开始 -> 控制面板 -> 控制面板 -> 凭据管理器

  2. 相反,您可以使用以下命令要求 git 使用其缓存中的凭据

    git config --global credential.helper cache

    通过这样做,git 将在每次与远程源交互时提示输入用户名和密码。

Hope this helps!

希望这可以帮助!