当我试图在Windows上使用git Bash拉代码时,我有以下问题:
fatal: could not read Username for 'https://github.com': No such file or directory
我已经尝试实现这里提供的可接受的解决方案:
当推送提交Github时错误:致命:无法读取用户名
然而,问题仍然存在。
在添加/删除原点后,我仍然得到相同的错误。
你能给我一些建议吗?
谢谢!
当我试图在Windows上使用git Bash拉代码时,我有以下问题:
fatal: could not read Username for 'https://github.com': No such file or directory
我已经尝试实现这里提供的可接受的解决方案:
当推送提交Github时错误:致命:无法读取用户名
然而,问题仍然存在。
在添加/删除原点后,我仍然得到相同的错误。
你能给我一些建议吗?
谢谢!
当前回答
对于我来说,上面建议的没有任何工作,我使用了Jenkins Shell Script中的git pull命令,显然它需要错误的用户名。我花了很长时间才找到一种不切换到SSH的方法来修复它。
在你的用户文件夹中创建。gitconfig文件(如果你还没有的话),并把你的凭证放在以下格式:https://user:pass@example.com,更多信息。在你的.gitconfig文件链接到这些凭证之后,在我的情况下,它是:
[credential]
helper = store --file /Users/admin/.git-credentials
现在git无论如何都会使用这些凭证。我希望它能帮助别人,就像它帮助了我一样。
其他回答
按照步骤在这里设置SSH密钥:https://help.github.com/articles/generating-ssh-keys
OR
git remote add origin https://{username}:{password}@github.com/{username}/project.git
更新:如果你得到"fatal: remote origin already exists.",那么你必须使用set-url:
git remote set-url origin https://{username}:{password}@github.com/{username}/project.git
如果你的回购是私人的
而不是这种格式
https://github.com/username/<project_name>.git
使用这种格式
git@github.username/<project_name>.git
您可以在SSH选项下获得正确的url
去你的Github回购->点击代码->选择SSH ->复制你的回购URL
希望这能有所帮助。
早些时候,当我没有获得访问回购的权限时,我还将SSH pubkey添加到gitlab。在这一点上,我可以访问回购和运行去mod供应商,同样的问题发生了。(可能是因为缓存)
go mod vendor
go: errors parsing go.mod:
/Users/macos/Documents/sample/go.mod:22: git ls-remote -q https://git.aaa.team/core/some_repo.git in /Users/macos/go/pkg/mod/cache/vcs/a94d20a18fd56245f5d0f9f1601688930cad7046e55dd453b82e959b12d78369: exit status 128:
fatal: could not read Username for 'https://git.aaa.team': terminal prompts disabled
经过一段时间的尝试,我决定删除SSH密钥和终端提示填写用户名和密码。那么一切都好了!
我也面临着同样的问题。当我使用HTTPS URL克隆一个repo,然后尝试推送更改(在Linux/Mac上使用Shell或在Windows上使用Git Bash)时,出现了这个问题:
git clone https://github.com/{username}/{repo}.git
但是,当我使用SSH URL克隆时,这个问题没有发生:
git clone git@github.com:{username}/{repo}.git
如果你已经使用HTTPS克隆了repo,并且不想重做所有事情,你可以使用set-url将原始URL更改为SSH URL:
git remote set-url origin git@github.com:{username}/{repo}.git
注意:我有SSH密钥添加到我的GitHub帐户。如果没有设置SSH密钥,这种方法也不能工作。
注意,如果你得到这个错误:
fatal: could not read Username for 'https://github.com': No error
然后,您需要将Git更新到2.16或更高版本。