git 使用 Github 推送提交时出错:致命:无法读取用户名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20871549/
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
Error when push commits with Github: fatal: could not read Username
提问by JohnDoe66
Since few time, I use Github for my projects and I have an issue when I want to push commits.
很少有时间,我将 Github 用于我的项目,当我想推送提交时遇到了问题。
To beginning, I have forked a repository. Then I have cloned the fork (with command line git clone https://github.com/ ...
) and, after doing modifications, I have committed with success (git commit -a
).
首先,我已经分叉了一个存储库。然后我克隆了 fork(使用命令行git clone https://github.com/ ...
),并且在进行修改后,我已经成功提交(git commit -a
)。
After this, I have tried to push commits with command line git push
but I obtain the following error:
在此之后,我尝试使用命令行推送提交,git push
但出现以下错误:
fatal: could not read Username for 'https://github.com': No such file or directory
Have you got an idea to resolve this issue?
你有解决这个问题的想法吗?
回答by Rodrigo Medeiros
What I had to do was:
我必须做的是:
git remote rm origin
git remote add origin '[email protected]:username/repo.git'
git remote rm origin
git remote add origin '[email protected]:username/repo.git'
Then, I was able to push my changes.
然后,我能够推动我的更改。
回答by Pulkit
I tried following command and it worked for me
我尝试了以下命令,它对我有用
git push https://<username>:<password>@github.com/<username>/<repository-name>
回答by Mr_and_Mrs_D
Well I had the same problem - what annoys me to no end is that I don't have a clue why(edit: bug). I was pushing with https
. Manually editing the config did not work for me (or doing a chkdsk as suggested in another answer). I ended up pushing with ssh - as in, replace:
好吧,我遇到了同样的问题-让我无休止地烦恼的是我不知道为什么(编辑:错误)。我在用https
. 手动编辑配置对我不起作用(或按照另一个答案中的建议执行 chkdsk)。我最终用 ssh 推动 - 如,替换:
https://github.com/USER/REPO.git
with
和
[email protected]:USER/REPO.git
after generating your keys
EDITas to why : it is a bug in 1.8.5. See the reportand a discussionwith a way to workaround
回答by Ricardo
回答by AndyL
This seems to be a known bug in Git 1.8.5 on Windows. As described and reported by @Mr_and_Mrs_D:
这似乎是 Windows 上 Git 1.8.5 中的一个已知错误。正如@Mr_and_Mrs_D 所描述和报道的:
https://groups.google.com/forum/#!msg/msysgit/s4dB8Nv9V4c/55-cGPdPYmAJ
https://groups.google.com/forum/#!msg/msysgit/s4dB8Nv9V4c/55-cGPdPYmAJ
Downgrading to 1.8.4 works for me. Please note you have to explicitly uninstall 1.8.5 first by running C:\Program Files (x86)\Git\unins000.exe
as described here:
降级到 1.8.4 对我有用。请注意,您必须首先C:\Program Files (x86)\Git\unins000.exe
按照此处所述运行来明确卸载 1.8.5 :
https://github.com/swcarpentry/bc/issues/234#issuecomment-33055444
https://github.com/swcarpentry/bc/issues/234#issuecomment-33055444
I downloaded 1.8.4 here: https://msysgit.googlecode.com/files/Git-1.8.4-preview20130916.exe
我在这里下载了 1.8.4:https: //msysgit.googlecode.com/files/Git-1.8.4-preview20130916.exe
回答by Dio Phung
In my case, I update Git to version 1.9 and this issue is fixed.
就我而言,我将 Git 更新到 1.9 版,此问题已修复。
During push/commit, the Git Bash will ask for Github's account & password.
在推送/提交期间,Git Bash 会询问 Github 的帐户和密码。
回答by Ari Malinen
For me the issue was i hadnt rw access to /dev/tty. Adding my user to tty group solved the problem (gpasswd -a tty).
对我来说,问题是我没有 rw 访问 /dev/tty。将我的用户添加到 tty 组解决了问题(gpasswd -a tty)。
回答by houbena
This workaround: git remote rm origin git remote add origin '[email protected]:username/repo.git'
此解决方法: git remote rm origin git remote add origin '[email protected]:username/repo.git'
caused a following error, which could be fixed only by recreating the build: ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
导致以下错误,只能通过重新创建构建来修复:错误:找不到任何要构建的修订版。验证此作业的存储库和分支配置。
so don't try it unless you know what you're doing!
所以除非你知道自己在做什么,否则不要尝试!
回答by Matthias Winkelmann
I ran into this error when I had a nonexistent github repository configured as a project dependency.
当我将一个不存在的 github 存储库配置为项目依赖项时,我遇到了这个错误。
回答by Kevin Tong
I used git-credential-winstore before. When I reinstalled my Windows, that error popep up. I resolve the issue by downloading git-credential-winstore again in my PATH.
我之前用过 git-credential-winstore 。当我重新安装 Windows 时,会弹出该错误。我通过在 PATH 中再次下载 git-credential-winstore 来解决该问题。