Windows 下的 Git bash 不提示输入密码

发布于 2025-01-03 01:47:09 字数 1071 浏览 0 评论 0原文

我是学生,对版本控制软件非常陌生,所以我很难弄清楚这一点。我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

走过海棠暮 2025-01-10 01:47:09

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

  1. 启动
  2. 类型:凭据管理器
  3. 双击 Windows 凭据管理器快捷方式
  4. 单击“Windows 凭据”选项卡。
  5. 找到您要删除的凭据,它们将以“git:”开头,也可能以“ada:”开头。
  6. 单击凭据条目,它将打开该条目的详细信息视图。
  7. 单击“删除”以删除,或单击“编辑”以更新密码

信用: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:

  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

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

北斗星光 2025-01-10 01:47:09

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


也就是说,这可能工作:

采取从上面显示的网址(您必须访问该网站):

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

machine code.google.com 登录 [电子邮件受保护] 密码 mypasswordXXX123

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):

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

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

×纯※雪 2025-01-10 01:47:09

ufk 的评论是正确答案。更明确地说,如果您使用推送,系统

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

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

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

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.

染柒℉ 2025-01-10 01:47:09

将以下命令放入 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

亽野灬性zι浪 2025-01-10 01:47:09

我遇到了与这里其他贡献者完全不同的问题。

对我来说,git 没有提示,因为我的存储库配置了 SSH 远程,而不是 HTTPS 远程。要验证您是否有相同的问题并修复它:

git remote -v
# View existing remotes
# origin  [email protected]/user/repo.git (fetch)
# origin  [email protected]/user/repo.git (push)

如果远程以 git@ 开头,请执行以下更改:

git remote set-url origin https://github.com/user/repo.git
# Change the 'origin' remote's URL

git remote -v
# Verify new remote URL
# origin  https://github.com/user/repo.git (fetch)
# origin  https://github.com/user/repo.git (push)

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:

git remote -v
# View existing remotes
# origin  [email protected]/user/repo.git (fetch)
# origin  [email protected]/user/repo.git (push)

If the remote begins with git@, perform this change:

git remote set-url origin https://github.com/user/repo.git
# Change the 'origin' remote's URL

git remote -v
# Verify new remote URL
# origin  https://github.com/user/repo.git (fetch)
# origin  https://github.com/user/repo.git (push)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文