noo*_*php 70 git github git-pull git-bash
当我尝试在Windows上使用GIT Bash来提取代码时,我遇到以下问题
我已经尝试实现此处提供的已接受解决方案:
但问题仍然存在.添加/删除原点后,我仍然得到相同的错误.
fatal: could not read Username for 'https://github.com': No such file or directory
Run Code Online (Sandbox Code Playgroud)
Ton*_*gna 52
按照以下步骤设置SSH密钥:https://help.github.com/articles/generating-ssh-keys
要么
git remote add origin https://{username}:{password}@github.com/{username}/project.git
Run Code Online (Sandbox Code Playgroud)
Ham*_*emi 25
只需检查以下内容
Android Studio -> 首选项 -> 版本控制 -> Git -> 使用凭据助手
Lou*_*kin 17
我在这里找到了答案:
编辑~/.gitconfig并添加以下内容:
[url "git@github.com:"]
insteadOf = https://github.com/
Run Code Online (Sandbox Code Playgroud)
虽然它解决了不同的问题,但错误代码是相同的......
Kat*_*tia 13
对我来说,上面的建议没有任何效果,我使用git pull了 jenkins shell 脚本,显然它使用了错误的用户名。我花了很长时间才找到一种无需切换到 SSH 即可修复它的方法。
在您的用户文件夹中创建 .gitconfig 文件(如果您还没有)并将您的凭据放入以下格式:https://user:pass@example.com, more info。在您的 .gitconfig 文件链接到这些凭据后,在我的情况下是:
[credential]
helper = store --file /Users/admin/.git-credentials
现在 git 将始终使用这些凭据,无论如何。我希望它会帮助某人,就像它帮助了我一样。
Fay*_*yaz 10
我遇到了同样的问题.当我使用HTTPS URL克隆然后尝试使用Git Bash在Windows上使用以下命令推送更改时,会发生此问题:
git clone https://github.com/{username}/{repo}.git
Run Code Online (Sandbox Code Playgroud)
但是,当我使用SSH URL进行克隆时,没有出现此问题:
git clone git@github.com:{username}/{repo}.git
Run Code Online (Sandbox Code Playgroud)
小智 9
TL;DR:检查您是否可以读取/写入/dev/tty. 如果没有,并且您已经使用过su打开外壳,请检查您是否正确使用。
我遇到了同样的问题,但在 Linux 上我发现了这个问题。我没有存储我的凭据,因此我总是在提示时输入它们:
Username for 'https://github.com': foo
Password for 'https://foo@github.com':
Run Code Online (Sandbox Code Playgroud)
git 处理 http(s) 连接的方式是使用/usr/lib/git-core/git-remote-https
你可以在这里看到 strace :
stat("/usr/lib/git-core/git-remote-https", {st_mode=S_IFREG|0755, st_size=1366784, ...}) = 0
pipe([9, 10]) = 0
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f65398bb350) = 18177
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
close(10) = 0
read(9, "", 8) = 0
close(9) = 0
close(5) = 0
close(8) = 0
dup(7) = 5
fcntl(5, F_GETFL) = 0 (flags O_RDONLY)
write(6, "capabilities\n", 13) = 13
fstat(5, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
read(5, "fetch\noption\npush\ncheck-connecti"..., 4096) = 38
write(6, "option progress true\n", 21) = 21
read(5, "ok\n", 4096) = 3
write(6, "option verbosity 1\n", 19) = 19
read(5, "ok\n", 4096) = 3
stat(".git/packed-refs", {st_mode=S_IFREG|0664, st_size=675, ...}) = 0
lstat(".git/objects/10/52401742a2e9a3e8bf068b115c3818180bf19e", {st_mode=S_IFREG|0444, st_size=179, ...}) = 0
lstat(".git/objects/4e/35fa16cf8f2676600f56e9ba78cf730adc706e", {st_mode=S_IFREG|0444, st_size=178, ...}) = 0
dup(7) = 8
fcntl(8, F_GETFL) = 0 (flags O_RDONLY)
close(8) = 0
write(6, "list for-push\n", 14) = 14
read(5, fatal: could not read Username for 'https://github.com': No such device or address
"", 4096) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=18177, si_uid=1000, si_status=128, si_utime=6, si_stime=2} ---
exit_group(128) = ?
+++ exited with 128 +++
Run Code Online (Sandbox Code Playgroud)
所以我尝试直接调用它:
echo "list for-push" | strace /usr/lib/git-core/git-remote-https my
Run Code Online (Sandbox Code Playgroud)
结果:
poll([{fd=3, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 1 ([{fd=3, revents=POLLIN|POLLRDNORM}])
recvfrom(3, "\27\3\3\1\32", 5, 0, NULL, NULL) = 5
recvfrom(3, "\307|4Q\21\306\334\244o\237-\230\255\336\25\215D\257\227\274\r\330\314U\5\17\217T\274\262M\223"..., 282, 0, NULL, NULL) = 282
openat(AT_FDCWD, "/dev/tty", O_RDONLY) = -1 ENXIO (No such device or address)
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=2995, ...}) = 0
read(4, "# Locale name alias data base.\n#"..., 4096) = 2995
read(4, "", 4096) = 0
close(4) = 0
openat(AT_FDCWD, "/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "fatal: could not read Username f"..., 83fatal: could not read Username for 'https://github.com': No such device or address
) = 83
exit_group(128) = ?
+++ exited with 128 +++
Run Code Online (Sandbox Code Playgroud)
我想到了:
openat(AT_FDCWD, "/dev/tty", O_RDONLY) = -1 ENXIO (No such device or address)
...
write(2, "fatal: could not read Username f"..., 83fatal: could not read Username for 'https://github.com': No such device or address
) = 83
Run Code Online (Sandbox Code Playgroud)
git-remote-https尝试通过以下方式读取凭据/dev/tty,因此我测试了它是否有效:
$ echo ahoj > /dev/tty
bash: /dev/tty: No such device or address
Run Code Online (Sandbox Code Playgroud)
但在另一个终端中:
# echo ahoj > /dev/tty
ahoj
Run Code Online (Sandbox Code Playgroud)
我知道我使用切换到这个用户su,所以我退出 shell 看看如何,发现我使用了命令,su danman -所以我再次测试了它:
~# su danman -
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
/root$ echo ahoj > /dev/tty
bash: /dev/tty: No such device or address
Run Code Online (Sandbox Code Playgroud)
我可能忽略了该消息并继续工作,但这就是原因。当我切换使用正确的方式时,su - danman一切正常:
~# su - danman
danman@speedy:~$ echo ahoj > /dev/tty
ahoj
Run Code Online (Sandbox Code Playgroud)
之后,git开始正常工作
如果您想继续使用 https 而不是 ssh,并且出于安全原因避免输入您的用户名和密码。
您也可以尝试Github OAuth token,然后您可以执行
git config remote.origin.url 'https://{token}@github.com/{username}/{project}.git'
或
git remote add origin 'https://{token}@github.com/{username}/{project}.git'
这对我有用!
小智 5
尝试克隆无效的 HTTP URL 时也可能发生此错误。例如,这是我在尝试克隆一个有几个字符的 GitHub URL 时遇到的错误:
$ git clone -v http://github.com/username/repo-name.git
Cloning into 'repo-name'...
Username for 'https://github.com':
Password for 'https://github.com':
remote: Repository not found.
fatal: Authentication failed for 'https://github.com/username/repo-name.git/'
Run Code Online (Sandbox Code Playgroud)
不过,它实际上发生在 Emacs 内部,因此 Emacs 中的错误如下所示:
fatal: could not read Username for ’https://github.com’: No such device or address
Run Code Online (Sandbox Code Playgroud)
因此,与其说那个 URL 上没有这样的 repo 有帮助的错误,它给了我这个错误,让我大吃一惊,直到我最终意识到 URL 是不正确的。
这是 git 版本 2.7.4。
我在这里发布这个是因为它发生在我一个月前和刚刚发生在我身上,再次让我陷入同样的疯狂追逐。>:(
这里什么都试过了,没用。
然而,当我尝试通过 调试时git config --system --list,我得到了fatal: unable to read config file '/etc/gitconfig': No such file or directory.
所以我做了以下事情,
sudo ln -s $HOME/.gitconfig /etc/gitconfig
Run Code Online (Sandbox Code Playgroud)
瞧,它有效了。
这是系统凭证缓存中存储的凭证的问题。您可能将配置变量“credential.helper”设置为 wincred 或 winstore,但无法清除它。如果启动控制面板并启动凭据管理器小程序,则在通用凭据部分中查找标记为 的项目git:https://github.com。如果您删除这些凭据,则下次将重新创建这些凭据,但凭据帮助程序实用程序将要求您提供新凭据。
| 归档时间: |
|
| 查看次数: |
125345 次 |
| 最近记录: |