從Git刪除憑證

本文翻譯自:Remove credentials from Git

I'm working with several repositories, but lately I was just working in our internal one and all was great. 我正在使用多個存儲庫,但是最近我只在內部存儲庫中工作,一切都很棒。

Today I had to commit and push code into other one, but I'm having some troubles. 今天,我不得不提交代碼並將其推送到其他代碼中,但是我遇到了一些麻煩。

$ git push appharbor master
error: The requested URL returned error: 403 while accessing https://[email protected]/mitivo.git/info/refs?service=git-receive-pack
fatal: HTTP request failed

There is nothing I can do, that would bring the password entry again. 我無能爲力,這將再次帶來密碼輸入。

How can I reset the credentials on my system so Git will ask me for the password of that repository? 如何重置系統上的憑據,以便Git詢問我該存儲庫的密碼?

I have tried: 我努力了:

  • git config --global --unset core.askpass

in order to unset the password 爲了取消密碼

  • git config credential.helper 'cache --timeout=1'

in order to avoid credentials cache... 爲了避免憑證緩存...

Nothing seems to work; 似乎沒有任何作用; does anyone have a better idea? 有誰有更好的主意嗎?


#1樓

參考:https://stackoom.com/question/12XLq/從Git刪除憑證


#2樓

如果使用密鑰對進行了身份驗證,則可以刪除或移動私鑰,或者停止密鑰代理並嘗試。


#3樓

The Git credential cache runs a daemon process which caches your credentials in memory and hands them out on demand. Git憑證緩存運行一個守護進程,該進程將您的憑證緩存在內存中並按需分發。 So killing your git-credential-cache--daemon process throws all these away and results in re-prompting you for your password if you continue to use this as the cache.helper option. 因此,殺死git-credential-cache--daemon進程會丟棄所有這些東西,如果繼續使用它作爲cache.helper選項,則會導致重新提示您輸入密碼。

You could also disable use of the Git credential cache using git config --global --unset credential.helper . 您還可以使用git config --global --unset credential.helper禁用Git憑據緩存。 Then reset this, and you would continue to have the cached credentials available for other repositories (if any). 然後重置此設置,您將繼續擁有可用於其他存儲庫(如果有)的緩存憑據。 You may also need to do git config --system --unset credential.helper if this has been set in the system configuration file (for example, Git for Windows 2). 如果已在系統配置文件(例如,用於Windows 2的Git)中設置了git config --system --unset credential.helper則可能還需要執行git config --system --unset credential.helper

On Windows you might be better off using the manager helper ( git config --global credential.helper manager ). 在Windows上,最好使用管理器幫助git config --global credential.helper manager )。 This stores your credentials in the Windows credential store which has a Control Panel interface where you can delete or edit your stored credentials. 這會將您的憑據存儲在Windows憑據存儲中,該憑據存儲具有控制面板界面,您可以在其中刪除或編輯存儲的憑據。 With this store, your details are secured by your Windows login and can persist over multiple sessions. 通過此存儲,您的詳細信息受Windows登錄名保護,並且可以在多個會話中保留。 The manager helper included in Git for Windows 2.x has replaced the earlier wincred helper that was added in Git for Windows 1.8.1.1. Windows 2.x的Git中包含的管理器幫助程序已替換了Windows 1.8.1.1的Git中添加的較早的wincred幫助程序。 A similar helper called winstore is also available online and was used with GitExtensions as it offers a more GUI driven interface. 一個類似的名爲winstore的幫助程序也可以在線獲得,並與GitExtensions一起使用,因爲它提供了更多的GUI驅動界面。 The manager helper offers the same GUI interface as winstore . 管理器幫助程序提供與winstore相同的GUI界面。

Extract from the Windows manual detailing the Windows credential store panel: Windows手冊中摘錄,詳細介紹Windows憑據存儲面板:

Open User Accounts by clicking the Start button Picture of the Start button, clicking Control Panel, clicking User Accounts and Family Safety (or clicking User Accounts, if you are connected to a network domain), and then clicking User Accounts. 通過單擊“開始”按鈕“開始”按鈕的圖片,單擊“控制面板”,單擊“用戶帳戶和家庭安全”(或如果連接到網絡域,則單擊“用戶帳戶”),然後單擊“用戶帳戶”,以打開用戶帳戶。 In the left pane, click Manage your credentials. 在左窗格中,單擊“管理您的憑據”。


#4樓

Remove this line from your .gitconfig file located in the Windows' currently logged-in user folder: 從Windows當前登錄用戶文件夾中的.gitconfig文件中刪除以下行:

[credential]
helper = !\"C:/Program Files (x86)/GitExtensions/GitCredentialWinStore/git-credential-winstore.exe\"

This worked for me and now when I push to remote it asks for my password again. 這對我有用,現在當我按下遙控器時,它會再次要求我輸入密碼。


#5樓

Retype: 重新輸入:

$ git config credential.helper store

And then you will be prompted to enter your credentials again. 然後將提示您再次輸入您的憑據。

WARNING 警告

Using this helper will store your passwords unencrypted on disk 使用此幫助程序會將密碼未加密地存儲在磁盤上

Source: https://git-scm.com/docs/git-credential-store 資料來源: https : //git-scm.com/docs/git-credential-store


#6樓

I found something that worked for me. 我找到了對我有用的東西。 When I wrote my comment to the OP I had failed to check the system config file: 當我向OP寫評論時,我未能檢查系統配置文件:

git config --system -l

shows a 顯示一個

credential.helper=!github --credentials

line. 線。 I unset it with 我取消了

git config --system --unset credential.helper

and now the credentials are forgotten. 現在忘記了憑據。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章