---
# System prepended metadata

title: Github 個人權杖更新步驟：解決 git push 失敗，取代密碼驗證

---

# Github 個人權杖更新步驟：解決 git push 失敗，取代密碼驗證

![](https://i.imgur.com/kwCl41b.png)
>Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.）

專案 commit 完無法 git push，顯示 github 不再支援帳號密碼驗證，比須改以「個人權杖（Personal Access Token）」作為驗證工具。

根據 [Github 官方文件](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token)教學，可以先設定個人權杖後再做密碼變更，即可完成。


1. 確保 github 已驗證過 email
2. 點擊 github 個人頭像處，找到 settings
![](https://i.imgur.com/nlTfRlo.png)

3. 點擊左側下方 Developer Setting
![](https://i.imgur.com/TMjQBgu.png)

4. 點擊左下 Personal access token
![](https://i.imgur.com/FMOcwIq.png)

5. 點擊 Generate new token
![](https://i.imgur.com/fhgfUzu.png)

6. 在 Note 寫下權杖的用途，並設定期效
![](https://i.imgur.com/Kao1UVS.png)

7. 在 Select scopes 處選取權杖的使用範圍。如果想要以此權杖用來在CLI 上存取 repository，則一定要勾選 **repo**。
![](https://i.imgur.com/bred9qF.png)

8. 按下 Generate Token
![](https://i.imgur.com/EAJWUt9.png)

9. 個人權杖即產生！
![](https://i.imgur.com/Ee0ySJB.png)

**請務必複製下並儲存於安全處，這串序號將不復見**

接著要將原本的密碼改為剛剛創建的個人權杖，以下示範 Mac OS 的操作

1. 在 Mac 上搜尋 Keychain（鑰匙圈）

2. 按下左上「登入」，找到 github 的 internet 密碼的項目
![](https://i.imgur.com/6faEuC3.png)


3. 勾選「顯示密碼」，系統會先請你輸入 **原先的密碼**（注意！不是輸入個人權杖喔！）
![](https://i.imgur.com/lbshnsE.png)

4. 於顯示密碼後方欄位貼上個人權杖，並按下右下方「儲存所作更動」鍵。
![](https://i.imgur.com/OIAKT5w.png)


5. 完成！！！
馬上試試 git push，成功！
![](https://i.imgur.com/xjN5tfu.png)



參考資料：

https://www.ithome.com.tw/news/141715

https://stackoverflow.com/questions/68779331/use-token-to-push-some-codes-to-github










