Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为现有私有回购添加新的github令牌?_Git_Github - Fatal编程技术网

如何为现有私有回购添加新的github令牌?

如何为现有私有回购添加新的github令牌?,git,github,Git,Github,我不得不撤销旧的Github代币进行私人回购 现在从Github生成了一个新令牌 如何将此旧代币添加到现有回购协议中 如果不更新此新令牌,推/拉操作将失败: git push origin master remote: Invalid username or password. fatal: Authentication failed for.... 如果我能重新克隆回购协议,我知道如何解决这个问题。但是,我希望避免再次克隆回购协议。GitHub令牌实际上存在于帐户级别,而

我不得不撤销旧的Github代币进行私人回购

现在从Github生成了一个新令牌

如何将此旧代币添加到现有回购协议中

如果不更新此新令牌,推/拉操作将失败:

git push origin master          
remote: Invalid username or password.
fatal: Authentication failed for....

如果我能重新克隆回购协议,我知道如何解决这个问题。但是,我希望避免再次克隆回购协议。

GitHub令牌实际上存在于帐户级别,而不是回购级别


有关如何将令牌添加到帐户的说明,请参见:

我必须编辑
.git/config
并使用用户正确的令牌更新URL

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = https://<user>:<token-id>@github.com/user/repo.git
[远程“源站”]
fetch=+refs/heads/*:refs/remotes/origin/*
url=https://:@github.com/user/repo.git

此处
令牌id
设置为更新后的令牌id。

您是否尝试查看正在使用的Git客户端手册的“身份验证”部分?如果是的话,你使用哪一个客户?你尝试过什么?对我来说很有用。您知道将令牌存储在
.git/config
中是否被认为是安全/良好的做法吗?