MacOS El CapitanのSourcetreeでGitHubにプッシュ

GitHub Desktop 2.2.2がまともに動かないので,Sourcetree 2.7.6を使うことにした。しかし,ここでまた問題発生。GitHubにプッシュしようとすると,次のメッセージが表示された。

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree commit -q -F /var/folders/r1/knl8dbsd14zf3qtn2tzr4ljm0000gn/T/SourceTreeTemp.9cRxc9

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags --set-upstream origin refs/heads/master:refs/heads/master
Pushing to https://github.com/user/repository.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/user/repository.git/'

パスワード認証のサポートは2021年8月13日に終了しているとのこと。GitHub Desktopはパスワード認証で使っていた気がするのだが,よく分からない。理由は不明だが,確実なのは使えないことである。
他にも困っている人はいるようで,解決方法を見つけた ([Solved] remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. | NamespaceIT)。

  1. GitHub.comのウェブサイトにログインしてPersonal access tokenを発行する。Personal access tokenの有効期限は最長3か月なので,3か月したらまた同じ作業をしなければならない。
  2. Sourcetreeのアカウント設定画面で以下のように設定して保存する。
Sourcetreeアカウント設定
  1. (これは必須かは分からないが) Macで「キーチェーンアクセス」を起動し,github.comの「インターネットパスワード」の項目を探し,「パスワードを表示」欄からパスワードを編集してPersonal access tokenを貼り付ける。

これでプッシュができるようになった。しばらくは使えそうである。