# Sourcetree 「fatal: Authentication failed 」 問題解決筆記 #### 問題 使用sourcetree 將repo push至遠端時,輸入完Github帳號密碼會一直輸下下列錯誤訊息 『 Pushing to https://github.com/RitaYang0811/github0620_test.git remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication. fatal: Authentication failed for 'https://github.com/RitaYang0811/github0620_test.git/'』 原因是 github 從 August 13, 2021 之後,對於 git 相關的存取已不再支援 password,須改用token方式進行。 ## 方法一: #### step1 - 在Github右手邊點選settings  #### step2 - 在右側點選Developer settings  #### step3 - 選擇Personal access tokens(classic)  #### step4 - 點選Generate new tokens  #### step5/6/7 - 為tokens取/設定有效期限/選擇可用範圍  #### step8 - 生成的token須妥善保存 那一串長長的數字只會出現一次,沒複製到就只能再生成 一次囉! #### step9 - 把那傳長長的tokens貼到sourcetree需打密碼的地方,問題解決! ## 方法二: 可以不用每次都一直生成token,但我還沒嘗試過,先筆記起來。 這個方法不是用token取代密碼,而是直接將token崁在remote裡。 #### 新建一個remote,裡面含帳號及token ``` git remote set-url origin https://<githubtoken>@github.com/<username>/<repositoryname>.git ``` 範例: ``` git remote set-url origin https://XXXXXXXXXXXXXXXXXXX@github.com/ritayang0811/test_repo.git ``` 資料參考: https://www.wongwonggoods.com/all-posts/other-skill/debug_error/git-remote-support/#%E5%95%8F%E9%A1%8C%E6%8F%8F%E8%BF%B0 https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up