Windows 下的 Git bash 不提示输入密码
我是学生,对版本控制软件非常陌生,所以我很难弄清楚这一点。我正在使用 Google 代码 Git 存储库。为了访问此存储库,我在 Windows 7 上使用 Git Bash。问题是,当我到达推送步骤时,系统不会提示我输入密码。例如:
首先,我设置如下全局变量:
git config --global user.name "Your Name"
git config --global user.email [email protected]
克隆
$ git clone https://[email protected]/p/repository/
然后我对文件进行了更改/添加了新文件等,并添加了
$ git add .
提交
$ git commit -m "Message"
拉取以确保我是最新的
$ git pull
Already up-to-date.
但是当我推送时,没有提示我输入密码
$ git push origin master
fatal: remote error: Invalid username/password.
You may need to use your generated googlecode.com password; see https://code.goo
gle.com/hosting/settings
有什么建议吗?谢谢。
I am student, and very new to version control software so I am having trouble figuring this out. I am using a Google code Git repository. To access this repository I am using Git Bash on Windows 7. The problem is that when I reach the push step, I am not being prompted for a password. For example:
First I set global variables like this:
git config --global user.name "Your Name"
git config --global user.email [email protected]
Cloned
$ git clone https://[email protected]/p/repository/
Then I made changes to files / added new files etc. and added
$ git add .
Committed
$ git commit -m "Message"
Pulled to make sure I am up to date
$ git pull
Already up-to-date.
But when I push I am not prompted for password
$ git push origin master
fatal: remote error: Invalid username/password.
You may need to use your generated googlecode.com password; see https://code.goo
gle.com/hosting/settings
Any suggestions? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
对于并非特定于 machine.google.com 的类似问题,您可以尝试删除或更新 Windows 凭据管理器中保存的 git 密码。我的系统已保存旧密码:
信用:https: //github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/141
For similar issues NOT specific to machine.google.com, you can try removing or updating the saved git password in windows credential manager. My system had my old password saved:
credit: https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/141
编辑:看起来您无法通过将用户名放入 URL 来成功访问 google 代码(至少截至 2011 年 8 月),请参阅:netrc 不被 git 接受
也就是说,这可能工作:
采取从上面显示的网址(您必须访问该网站):
machine code.google.com 登录 [ 上面的项目,看起来像在 Git 中Bash 你应该能够像这样更新你的 _netrc 文件:
echo "machine code.google.com login [电子邮件受保护] 密码 mypasswordXXX123" > $HOME/_netrc
Edit: Looks like you can't access google code successfully by putting the username in the URL (at least as of August 2011), see this: netrc not accepted by git
That said, this might work:
Taken from the URL shown above (you have to visit the site):
Once you have the above item, it looks like in Git Bash you should be able to update your _netrc file like this:
echo "machine code.google.com login [email protected] password mypasswordXXX123" > $HOME/_netrc
ufk 的评论是正确答案。更明确地说,如果您使用推送,系统
将提示您输入用户名和密码(假设 .netrc 未按照 OP 指定的方式设置)。除了 master 之外,您还可以指定另一个分支,但省略该分支可能不起作用。
The comment by ufk is the correct answer. To be more explicit, if you push with
you will be prompted for username and password (assuming .netrc is not set as specified by OP). Instead of master you could specify another branch, but omitting the branch probably won't work.
将以下命令放入 git bash
git config --global core.askpass /usr/libexec/git-core/git-gui--askpass
Put the following command in git bash
git config --global core.askpass /usr/libexec/git-core/git-gui--askpass
我遇到了与这里其他贡献者完全不同的问题。
对我来说,git 没有提示,因为我的存储库配置了 SSH 远程,而不是 HTTPS 远程。要验证您是否有相同的问题并修复它:
如果远程以
git@
开头,请执行以下更改:I had a completely different issue from the other contributors here.
For me, git was not prompting because my repo was configured with a SSH remote, not a HTTPS remote. To verify if you have the same issue and fix it:
If the remote begins with
git@
, perform this change: