🌟
WSL2でGit認証を毎回聞かれないようにする
概要
WSL2環境で快適(かつ安全)にGitを使用できるようにするため、Git Credential Manager for Windowsと、WSLのLinux環境を連携させます。
手順
Git Credential Manager for Windowsをインストールする
-
以下のページの
Download and Install
のlatest installer
を選択します。
https://github.com/microsoft/Git-Credential-Manager-for-Windows#download-and-install -
GCMW-{version}.exe
のファイルを選択してダウンロードしインストールを実行します。
WSL2(Ubuntu)側のCredential Manager呼び出し設定
Gitのglobal設定のcredential.helper
を、Windows側のCredential Managerを使うように設定することで、認証情報を安全に保存できるようになります。
- WSL2(Ubuntu)のコンソールで以下コマンドを実行します。
shell
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe"
初回PUSH時に認証情報を聞かれると思います。それ以降、認証情報を入れずに操作できるようになります。
Discussion