git-credential-manager-core.exe の確認
Git for Windows に同梱されている。なければ Git for Windows をインストールする。
PS C:\Program Files\Git\mingw64\bin> ls .\git-credential-manager-core.exe
Directory: C:\\Program Files\\Git\\mingw64\\bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 10/7/2022 12:22 75688 git-credential-manager-core.exe
Global の .gitconfig を編集する
Windows
PowerShell で git config --global credential.helper manager を実行する。
Ubuntu (WSL)
WSL でも Git 操作したいときは以下の credential の部分を追記する。
$ cat .\.gitconfig
[user]
email = hoge@example.com
name = hoge
[credential]
helper = /mnt/c/Program\\ Files/Git/mingw64/bin/git-credential-manager.exe
git clone などしたときに git.exe が見つからないエラーが発生したら、 Windows 側の PATH に git を追加する。

プライベートリポジトリ を Clone
https://ユーザー名@github.com とするのがポイント。
PS C:\> git clone https://hoge@github.com/org/repo.git
認証のための Web 画面が起動する。

今回は Browser/Deviceにする。 Personel Access Token の方が望ましい。

ブラウザが起動する。 2FA をしていれば、ここで入力し、 Authorize する。

成功する。

Clone が始まる。
