🐧
WSL上でVSCodeのSourcetreeが使えない件
はじめに
WSL上のフォルダはVSCodeのSourcetreeが使えないことに気づいたので、対処法をまとめました。
原因
この問題についてVSCodeの公式ドキュメントには、以下のように記載されていました。
VS Code uses git.exe for executing all git operations. Starting with Git 2.35.2, users are prevented from running git operations in a repository that is in a folder that owned by a user other than the current user as the repository is deemed to be potentially unsafe.
意訳すると別のユーザが所有しているフォルダはGitの操作を行えないそうです。
解決策
ということで、ユーザが所有していないディレクトリでもGit操作を行えるようにgit configコマンドで設定します。
git config --global --add safe.directory '%(prefix)///wsl.localhost/Ubuntu/home/ユーザ名/プロジェクト'
無事解決できましたが、毎回これを設定するのは面倒ですね...
Discussion