当我尝试在 Windows 上使用 Git Bash 拉取代码时,出现了以下问题:
fatal: could not read Username for 'https://github.com': No such file or directory
我已经尝试实施这里提供的被接受的解决方案:
然而问题仍然存在。
在添加/删除源之后,我仍然遇到相同的错误。
能否就此问题提供建议?
谢谢!
当我尝试在 Windows 上使用 Git Bash 拉取代码时,出现了以下问题:
fatal: could not read Username for 'https://github.com': No such file or directory
我已经尝试实施这里提供的被接受的解决方案:
然而问题仍然存在。
在添加/删除源之后,我仍然遇到相同的错误。
能否就此问题提供建议?
谢谢!
这里有一个简单的诀窍可行
android studio -> 设置 -> 版本控制 -> git -> 使用凭据助手
玩得开心!
简短回答:
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/{USER_NAME}/{REPOSITORY_NAME}.git
git push --set-upstream origin master
如果这不是一个新仓库,请忽略前三行。
详细说明:
我遇到了同样的问题,因为以上回答都没有帮助我,所以我决定发表这个解决方案,它对我有效。
一些注意事项:
作为命令行工具,我使用了GitShell(对于Windows,我使用Mac上的Terminal.app)。
GitShell是官方的GitHub工具,可以从https://windows.github.com/下载。
对于在Jenkins pipeline中遇到此错误的用户,可以使用SSH Agent插件来解决。随后,将您的git命令包装在类似以下方式中:
sshagent(['my-ssh-key']) {
git remote set-url origin git@github.com:username/reponame.git
sh 'git push origin branch_name'
}
将您的远程URL替换为以下内容:
git remote set-url origin https://<username>@github.com/<username>/<repo>.git
在我的情况下,我需要在GitHub上设置“个人访问令牌”:
设置 -> 开发者设置
并启用SSO。
[SSH] executing...
fatal: could not read Username for 'https://github.com': No such device or address
[SSH] completed
[SSH] exit-status: 1
Build step 'Execute shell script on remote host using ssh' marked build as failure
Finished: FAILURE
解决方案: 如果仓库是私有的并且属于其他人或组织,而您是该仓库的贡献者,则可以从Jenkins作业中运行git命令,它不会提示您输入用户名和密码。
https://用户名:令牌@github.com/账户名/仓库名.git
git pull
时也遇到了完全相同的问题,这个方法完美解决了。所需的权限是repo
和workflow
。在你的Github设置/秘密和变量/操作中设置令牌。 - undefined- name: 同步存储库与EC2
env:
HOST: ${{ secrets.HOST }}
USER: ${{ secrets.USERNAME}}
run: |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa $USER@$HOST "\
git config remote.origin.url 'https://${{ secrets.GH_PAT }}@github.com/${{ secrets.USERNAME}}/YOUR_REPO' && \
git pull origin main"
- undefinedgit:https://github.com
的通用凭据部分中的项目。如果您删除这些内容,下次将重新创建它们,但凭据助手实用程序将要求您提供新的凭据。git config --global -l | grep credential
。如果有任何输出,那就是试图在推送时向服务器提供存储凭据的实用程序。 - patthoytsgit remote add origin https://github.com/username/Hello-World.git
这个 git 仓库链接中绑定的 username
正在出现问题,我不认为我的 OWN username 在这里出了问题。据我所知,凭据管理器有助于管理个人凭据,而不是存储库的凭据。 - noobie-php
git config --global user.name "Your Name Here"
- Raul Andres