[英]How do I update the password for Git?
我正在使用帶有 Xcode 和 Git 的 BitBucket 進行版本控制,最近我更改了所有密碼(感謝 Adobe! )。
不出所料,我不再能夠將本地提交推送到 BitBucket 上的存儲庫( Authentication failed for 'https://______.git'
),但我忘記了如何更新 iMac 上的緩存密碼。 不知何故,我一直無法在 Google 或 Stack Overflow 上找到它,盡管在我看來它應該相當簡單......
要在 macOS 上修復此問題,您可以使用
git config --global credential.helper osxkeychain
用戶名和密碼提示將出現在您的下一個 Git 操作(拉、克隆、推送等)中。
對於 Windows,它是具有不同參數的相同命令:
git config --global credential.helper wincred
在 MacOS Sierra 10.12.4 上沒有其他答案對我有用
這是我必須做的:
git config --global --unset user.password
然后運行您的 git 命令(例如 git push)並重新輸入您的用戶名和密碼。
我可以修改我的 git 密碼的唯一方法是轉到 Windows 中的憑據管理器(Windows 鍵 + 鍵入“憑據”)並編輯 Windows 憑據 🡒 通用憑據下的 git 條目。 注:未按字母順序列出
我遇到了同樣的問題,接受的答案對我沒有幫助,因為密碼沒有存儲在鑰匙串中。 我輸入:
git pull https://myuser@bitbucket.org/mypath/myrepo.git
然后控制台詢問我的新密碼。
對於 Mac
如果您有多個遠程存儲庫(Github、Bitbucket、Job 等)
1)在項目目錄下運行
git config --unset user.password
2) 運行遠程 git 命令(即 git push 或 git pull)
Git 會提示你為這個倉庫重新輸入你的用戶名和用戶密碼
或者,如果您只有一個遠程存儲庫,則可以全局執行此操作
git config --global --unset user.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)
如果您是 MAC 用戶,那么您可以從 finder 打開 KeyChain Access Application,然后在那里查找您的帳戶。 只需單擊它並更新您的密碼。 現在嘗試一下,事情就會到位。
參考鏈接: 通過鑰匙串訪問更新您的憑據
為我工作。 :)
在我的Windows機器上,我嘗試了@nzrytmn的解決方案,即控制面板>搜索憑據>選擇“ManageCredentials”>在與我的用戶名對應的git選項類別下修改新憑據。 進而,
刪除當前密碼:
git config --global --unset user.password
添加了新密碼:
git config --global --add user.password "new_password"
它對我有用。
我是第一次推入存儲庫。 所以沒有定義HEAD
。
最簡單的方法是:
git push -u origin master
然后它會提示輸入密碼,一旦你輸入它就會自動保存,你就可以推送了。
如果您使用 github 並啟用了 2 因素身份驗證,則需要輸入個人訪問令牌而不是密碼
首先重置密碼:
git config --global --unset user.password
然后,登錄到您的 github 帳戶,在右上角,單擊設置,然后單擊開發人員設置。 生成個人訪問令牌。 復制它。
git push
終端將提示您輸入用戶名:輸入您的電子郵件地址。
在密碼提示下,輸入個人訪問令牌。
在這個問題上存在如此混亂,因為這個問題太復雜了。 第一個 MacOS 與 Win10。 然后是不同的身份驗證機制。
我將在這里開始一個統一的答案,可能需要一些幫助,如果我沒有得到幫助,我將繼續努力直到答案完成,但這需要時間。
視窗 10: |
|-- Run this command. You will be prompted on next push/pull to enter username and password:
| git config --global credential.helper wincred (Thanks to @Andrew Pye)
` MacOS:
|
|-- Using git config to store username and password:
| git config --global --add user.password
|
|---- first time entry
| git config --global --add user.password <new_pass>
|
|---- password update
| git config --global --unset user.password
| git config --global --add user.password <new_pass>
|
|-- Using keychain:
| git config --global credential.helper osxkeychain
|
|---- first time entry
| Terminal will ask you for the username and password. Just enter it, it will be
| stored in keychain from then on.
|
|---- password update
| Open keychain, delete the entry for the repository you are trying to use.
| (git remote -v will show you)
| On next use of git push or something that needs permissions, git will ask for
| the credentials, as it can not find them in the keychain anymore.
`
如果您的憑據存儲在憑據助手中,則刪除為特定主機保留的密碼的便攜方法是調用git credential reject
:
$ git credential reject
protocol=https
host=bitbucket.org
⏎
或者
$ git credential reject
url=https://bitbucket.org
⏎
之后,輸入你的新密碼,輸入git fetch
。
在 MacOS Big Sur 11.3.1 上沒有其他答案對我有用
我在 Github 上啟用了雙因素身份驗證,這使得即使輸入用戶名和密碼正確,您也會失敗。
這是我必須做的:
git config --global --unset user.password
然后運行您的 git 命令(例如 git push)並輸入您的用戶名。 對於密碼,您需要生成個人訪問令牌。
轉到
https://github.com/settings/profile
選擇右側的Developer Settings
。 選擇Personal Access Token
Generate new token
。 復制生成的令牌並將其用作終端中的密碼。
鑒於 2021 年 8 月 13 日起的新令牌身份驗證要求,這可能是您正在尋找的:
git remote remove origin
git remote add origin https://[TOKEN]@github.com/[USER]/[REPO]
git push
在終端中執行以下步驟:
刪除保存在 Mac 中的當前密碼
git config --global --unset user.password
使用此命令添加新密碼,替換為新密碼:
git config --global --add user.password <new_pass>
您可以在 2 個地方通過命令行更改密碼,以下將編輯憑據以連接 repo
git config --edit
憑證也可以使用全局參數在全局更改,如下所示
git config --global --add user.password "XXXX"
或設置憑據助手
git config --global credential.helper wincred
但如果你有回購級別的憑據設置使用第一個命令
git config --edit
我可以通過轉到 Windows 中的憑據管理器並刪除 Windows 憑據 🡒 通用憑據下的所有 git 條目來更改我的 git 密碼。
在執行 git pull 或 git push 時,windows 會要求輸入新的用戶/密碼本身。
我會嘗試在 Keychain Access 中刪除我的帳戶,然后再次運行git clone
。 Git 會要求我輸入新密碼。
只需克隆您現有的存儲庫之一,這將提示您輸入新憑據:
例如
git clone https://myuser@bitbucket.org/mypath/myrepo.git
// https://myuser@bitbucket.org/mypath/myrepo.git是您現有存儲庫之一的地址。
嘗試了一切,但沒有任何效果。 然后以下確實有效。
我的密碼在 github 桌面首選項中很好,但在 .git/config 文件中錯誤
對我來說唯一可行的解決方案是手動編輯文件:.git/config
包含這一行: url = https://user:password@github.com/user/repo.git
將密碼更改為 GOOD 密碼,因為它對我來說是舊密碼
在 mac BigSur 11.2.3 上,我更新了鑰匙鏈中的憑據,然后運行了以下命令。
git credential-osxkeychain erase
host=github.com
protocol=https
我必須這樣做,因為在更改為 github 的令牌身份驗證后,該線程中沒有其他解決方案對我有用。 github 一直說找不到存儲庫。 如果這不起作用,請嘗試將此與此線程中的其他 mac 命令結合使用。
對於那些正在尋找如何重置對存儲庫的訪問權限的人。 以 GitHub 為例。 您可以在您的個人資料的“設置 -> 開發者設置”中更改您的 GitHub 個人資料密碼並撤銷所有“個人訪問令牌”。 此外,您還可以選擇擦除所有 SSH/PGP 密鑰和 OAuth/GitHub 應用程序,以確保完全阻止對存儲庫的訪問。 因此,任何系統上的所有憑證管理器都將在授權失敗並提示您輸入新憑證。
以下步驟可以解決問題......
終端內的任何命令行選項都不適合我。 最終,我只是手動打開鑰匙串,在“所有項目”下搜索“git”,在那里找到一個條目並將其刪除。 做到了! 下次我嘗試從終端執行 git pull 時,它提示我輸入新憑據。
在這篇文章中,他們以一種非常簡單的方式解釋了它,但基本上,我們只需要執行一個git remote set-url origin "https://<yourUserName>@bitbucket.org/<yourRepo>"
並且下次你做git pull
或git push
你必須輸入你的密碼。
我將BitBucket與Xcode和Git一起用於版本控制,最近我更改了所有密碼(感謝Adobe! )。
毫不奇怪,我不再能夠將本地提交推送到BitBucket上的存儲庫中( Authentication failed for 'https://______.git'
),但是我忘記了如何更新iMac上的緩存密碼。 某種程度上,我一直無法在Google或Stack Overflow上找到它,盡管在我看來,它應該相當簡單……
對於 MAC 用戶,使用 git GUI(適用於 Sourcetree ,也可能適用於其他人)。 想對德里克的回答( https://stackoverflow.com/a/45703718/7138492 )添加一點評論。 原建議:
$ git config --global --unset user.password
應遵循的推/拉/讀取但是從GUI完成時可能無法正常工作。 %100 的工作情況是從控制台執行第一個連續的提示觸發 git 命令。 下面是一個例子:
$ git config --unset user.password
$ git push
然后它會要求您提供新密碼。
我遇到了同樣的問題(在 Windows 10 上,Git 版本 2.34.1.windows.1,使用個人訪問令牌和我的組織啟用的 SAML SSO):當我在我的倉庫中發出 git pull 時,我收到了錯誤消息
錯誤:“xxx”組織已啟用或強制執行 SAML SSO。 要訪問此存儲庫,您必須使用帶有個人訪問令牌的 HTTPS 遠程或帶有已為此組織授權的 SSH 密鑰和密碼的 SSH。 訪問https://docs.github.com/articles/authenticating-to-a-github-organization-with-saml-single-sign-on/了解更多信息。 致命:無法從遠程存儲庫中讀取。
我發現在我的 .git/config 文件中我有這個:url = git@github.com:myorg/myrepo.git
上面的錯誤消息中的鏈接統計信息使用 SAML SSO(個人訪問令牌,PAT)所以我將其更改為 url = https://www.github.com/myorg/myrepo.git
這一次,當發出 git pull 之類的 git 命令時,我看到了一個登錄對話框,我可以在其中提供我的 PAT 令牌並開始工作。
我正在使用 BitBucket 和 Xcode 和 Git 進行版本控制,最近我更改了所有密碼(感謝 Adobe! )。
不出所料,我無法再將本地提交推送到 BitBucket 上的存儲庫( Authentication failed for 'https://______.git'
),但我忘記了如何更新 iMac 上的緩存密碼。 不知何故,我一直無法在 Google 或 Stack Overflow 上找到它,盡管在我看來它應該相當簡單......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.