在.git配置中的个人访问令牌

huangapple go评论75阅读模式
英文:

Personal Access Token in .git config

问题

我在尝试从GitLab拉取时遇到了这个错误。

远程:HTTP基本认证:访问被拒绝。

提供的密码或令牌不正确,或者您的帐户启用了双因素身份验证(2FA),必须使用个人访问令牌而不是密码。

我没有启用2FA,并发现这个解决方案有效:

现在我的令牌已经存储在.git目录下的配置文件中。

我知道.git目录中包含足够的信息,可以从头开始还原整个项目。所以如果我推送项目,会暴露我的令牌吗?

英文:

I was getting this error when trying to pull from gitlab.

> remote: HTTP Basic: Access denied.
>
> The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password.

I don't have 2FA and found this solution to work:

Now my token is inside of the config file in .git.

I know that .git has enough information to restore the whole project from scratch. So if I push the project, will that expose my token?

答案1

得分: 1

No. Files inside the git dir (.git) are not tracked, Only the stuff from the work tree. Try cloning from the current repo to another folder on your machine. You will not find the token in the new clone - same for pushing.

e.g.

git clone C:\my-git D:\clone-of-my-git
英文:

No. Files inside the git dir (.git) are not tracked, Only the stuff from the work tree. Try cloning from the current repo to another folder on your machine. You will not find the token in the new clone - same for pushing.

e.g.

git clone C:\my-git D:\clone-of-my-git

huangapple
  • 本文由 发表于 2023年1月9日 17:21:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/75055215.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定