如何更新 Git 的密码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20195304/
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
How do I update the password for Git?
提问by Ken M. Haggerty
I'm using BitBucket with Xcode and Git for version control, and recently I changed all of my passwords (thanks Adobe!).
我正在使用 BitBucket 和 Xcode 和 Git 进行版本控制,最近我更改了所有密码(感谢 Adobe!)。
Unsurprisingly, I'm no longer able to push my local commits to my repository on BitBucket (Authentication failed for 'https://______.git'
), but I'm forgetting how to update the cached password on my iMac. Somehow I've been unable to find it on Google or Stack Overflow, though it seems to me it should be rather straightforward...
不出所料,我无法再将本地提交推送到 BitBucket ( Authentication failed for 'https://______.git'
)上的存储库,但我忘记了如何更新 iMac 上的缓存密码。不知何故,我一直无法在 Google 或 Stack Overflow 上找到它,尽管在我看来它应该相当简单......
回答by Ken M. Haggerty
To fix this on macOS, you can use
要在 macOS 上修复此问题,您可以使用
git config --global credential.helper osxkeychain
A username and password prompt will appear with your next Git action (pull, clone, push, etc.).
用户名和密码提示将出现在您的下一个 Git 操作(拉、克隆、推送等)中。
For Windows, it's the same command with a different argument:
对于 Windows,它是具有不同参数的相同命令:
git config --global credential.helper wincred
回答by Derek Lopes
None of the other answers worked for me on MacOS Sierra 10.12.4
在 MacOS Sierra 10.12.4 上没有其他答案对我有用
Here is what I had to do:
这是我必须做的:
git config --global --unset user.password
Then run your git command (ex. git push) and reenter your username and password.
然后运行您的 git 命令(例如 git push)并重新输入您的用户名和密码。
回答by Imran Javed
回答by bom1
The only way I could modify my git password was to go to Credential Manager in Windows (Windows Key + type 'credential') and edit the git entry under Windows Credentials Generic Credentials. Note: Not listed alphabetically
我可以修改我的 git 密码的唯一方法是转到 Windows 中的凭据管理器(Windows 键 + 键入“凭据”)并编辑 Windows 凭据通用凭据下的 git 条目。注:未按字母顺序列出
回答by Julián Martínez
I had the same problem, and the accepted answer didn't help me because the password wasn't stored in the keychain. I typed:
我遇到了同样的问题,接受的答案对我没有帮助,因为密码没有存储在钥匙串中。我输入:
git pull https://[email protected]/mypath/myrepo.git
Then console asked me for my new password.
然后控制台询问我的新密码。
回答by nzrytmn
In windows 10 at mentioned above by @Imran Javed you can find Generic Credentials at :
在@Imran Javed 上面提到的 Windows 10 中,您可以在以下位置找到通用凭据:
Control Panel\All Control Panel Items\Credential Manager --> Windows Credentials
控制面板\所有控制面板项\凭据管理器 --> Windows 凭据
for your git server and then you can update password by clicking edit button.
为您的 git 服务器,然后您可以通过单击编辑按钮更新密码。
回答by Shravan Ramamurthy
running git config --global --unset user.password
followed by any git command would prompt you to enter username and password.
运行git config --global --unset user.password
后跟任何 git 命令都会提示您输入用户名和密码。
git config --global --unset user.password
git push (will prompt you for the password)
git status (will not prompt for password again)
回答by Abhimanyu Sharma
In my Windows machine, I tried the solution of @nzrytmn i.e., Control Panel>Search Credentials>Select "ManageCredentials">modified new credentials under git option category corresponding to my username. And then,
在我的Windows机器上,我尝试了@nzrytmn的解决方案,即控制面板>搜索凭据>选择“ManageCredentials”>在与我的用户名对应的git选项类别下修改新凭据。进而,
Deleted current password:
删除当前密码:
git config --global --unset user.password
Added new password:
添加了新密码:
git config --global --add user.password "new_password"
And It worked for me.
它对我有用。
回答by Nishant
If you are MAC user then you can open KeyChain Access Application from finder and then look for your account listed there. Just click on it and update your password. Now give a try and things will fall in place.
如果您是 MAC 用户,那么您可以从 finder 打开 KeyChain Access Application,然后在那里查找您的帐户。只需单击它并更新您的密码。现在尝试一下,事情就会到位。
link for reference: Updating your credentials via Keychain Access
参考链接:通过钥匙串访问更新您的凭据
Worked for me. :)
对我来说有效。:)
回答by Pritam Banerjee
I was pushing into the repository for the first time. So there was no HEAD
defined.
我是第一次推入存储库。所以没有HEAD
定义。
The easiest way would be to:
最简单的方法是:
git push -u origin master
It will then prompt for the password, and once you enter that it will be saved automatically, and you will be able to push.
然后它会提示输入密码,一旦你输入它就会自动保存,你就可以推送了。