![](/img/trans.png)
[英]Why github ask username and password when to git push files in /var/www/html?
[英]When push in github, why git didn't ask me to type username and password?
这可能是个愚蠢的问题。 但我无法通过搜索找到任何关于此的信息。 也许,这是一个愚蠢的问题。
我已将代码存储在 github 中。
2 小时前,我想更新存储库中的代码,但我的本地没有该代码。 所以我克隆了它,修改了代码,然后推送了它。 这时候git提示我输入github的用户名和密码。 我输入了它并更新了代码。
之后,我在“其他”存储库中阅读了我的代码。 我也发现了一些需要修改的东西。 所以我将该存储库克隆到我的本地计算机,修改代码并推送它。
但是……这个时候git并没有提示输入github的用户名和密码的信息。
嗯? 这是否意味着任何人在 github 中克隆了我的代码也可以推送到我的 github 存储库? 这是非常危险的情况,不是吗?
所以我测试了在 github 中创建新存储库。 我将这个新存储库克隆到我的本地,进行了一些更改,然后推送了它。 但是 git 也不会提示输入用户名和密码的消息。
所以,我的问题是,
以下是我在执行上述工作时的命令。
$git init
$git clone https://github.com/[user name]/[repository name].git
<some change>
$git add *
$git commit -m "change"
$git remote add origin https://github.com/[user name]/[repository name].git
$git push origin master
添加了信息。 有关更多详细信息,我捕获了我的 github 设置页面。
这可能会有所帮助.. https://help.github.com/articles/caching-your-github-password-in-git/
默认情况下,Git 会将您的密码保存在缓存中 15 分钟。
对于 Mac 用户,可以通过运行以下命令清除密码:
git credential-osxkeychain erase
host=github.com
protocol=https
问题:推送到远程git时会报:remote: Permission to [your/repo] denied to user [bob]
商店中的用户名可能有误。 Powershell 这个:
cd c:\Program Files\Git\mingw64\libexec\git-core;
git-credential-manager.exe remove [bob];
git push origin [your branch];
现在应该会提示您输入凭据。
在 Linux 中检查
cat /home/<MyUser>/.git-credentials
据我所知,有几种使用 git 结帐的方法。
具体来说,使用 http 协议(使用名称/密码)和使用 ssh(使用 ssh 公钥/私钥对)
看来您正在使用 ssh,因此使用私钥/公钥对进行授权
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.