适用于 Windows 的 Git bash 不提示输入密码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9186835/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:26:52  来源:igfitidea点击:

Git bash for Windows NOT prompting for password

gitversion-controlgoogle-code

提问by Everhill

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:

我是学生,对版本控制软件非常陌生,所以我无法弄清楚这一点。我正在使用 Google 代码 Git 存储库。为了访问这个存储库,我在 Windows 7 上使用 Git Bash。问题是当我到达推送步骤时,我没有被提示输入密码。例如:

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.

有什么建议?谢谢。

采纳答案by Adam Rofer

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

编辑:看起来您无法通过将用户名放入 URL 来成功访问 google 代码(至少截至 2011 年 8 月),请参阅:netrc not accept by git



That said, this mightwork:

也就是说,这可能有效:

Taken from the URL shown above (you have to visit the site):

取自上面显示的 URL(您必须访问该站点):

For Git repositories, you can add the following line to your .netrc file recording your password for each repository domain you have commit access to. Make sure you have set the permissions on .netrc so that only your user account can read it.

machine code.google.com login [email protected] password mypasswordXXX123

对于 Git 存储库,您可以将以下行添加到 .netrc 文件中,记录您拥有提交访问权限的每个存储库域的密码。确保您已设置 .netrc 的权限,以便只有您的用户帐户可以读取它。

机器码.google.com 登录 [email protected] 密码 mypasswordXXX123

Once you have the above item, it looks like in Git Bash you should be able to update your _netrc file like this:

一旦你有了上面的项目,它看起来像在 Git Bash 中你应该能够像这样更新你的 _netrc 文件:

echo "machine code.google.com login [email protected] password mypasswordXXX123" > $HOME/_netrc

echo "machine code.google.com login [email protected] password mypasswordXXX123" > $HOME/_netrc

回答by Andrew Youdin

The comment by ufk is the correct answer. To be more explicit, if you push with

ufk 的评论是正确的答案。更明确地说,如果你推动

git push https://code.google.com/p/name-of-project/ master

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.

系统将提示您输入用户名和密码(假设 .netrc 未按照 OP 的指定设置)。您可以指定另一个分支而不是 master,但省略该分支可能不起作用。

回答by tb.

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:

对于非 machine.google.com 特有的类似问题,您可以尝试删除或更新 Windows 凭据管理器中保存的 git 密码。我的系统保存了我的旧密码:

  1. Start
  2. Type: Credential Manager
  3. Double-Click the Windows Credential Manager shortcut
  4. Click on the "Windows Credentials" tab.
  5. Locate the credentials that you want removed, they will start with "git:" and might begin with "ada:"
  6. Click on the credential entry, it will open a details view of the entry.
  7. Click Remove to remove, or Edit to Update the password
  1. 开始
  2. 类型:凭证管理器
  3. 双击 Windows 凭据管理器快捷方式
  4. 单击“Windows 凭据”选项卡。
  5. 找到您要删除的凭据,它们将以“git:”开头,也可能以“ada:”开头
  6. 单击凭证条目,它将打开条目的详细信息视图。
  7. 单击删除以删除,或单击编辑以更新密码

credit: https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/141

信用:https: //github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/141

回答by sathish m

Put the following command in git bash

将以下命令放入 git bash

git config --global core.askpass /usr/libexec/git-core/git-gui--askpass

git config --global core.askpass /usr/libexec/git-core/git-gui--askpass