ITのえんぴつ

Google Blockly開発者ツールやIT・プログラミングを研究して発信するブログ

【gitエラー】『git config --global--add safe.directory…』の対処方法

windows10から virtualbox に gitのリポジトリを作成し、 tortoisegit for win を使用して、このリポジトリを操作しようとしたら、 以下のようなgitエラーが発生しました。

Could not get HEAD hash.
libgit2 returned: repository path '//192.168.XX.XX/project1' is not owned by current user.

To add an exception for this directory, call:git config --global--add safe.directory '//192.168.XX.XX/project1'

そして、このgitエラーを解決するため、以下のコマンドを実行

git config --global --add safe.directory '192.168.XX.XX/project1'

すると、windows10からvirtualbox にある gitのリポジトリを操作できるようになりました。

上記のコマンドでうまくいかない人へ

以下のコマンドも試してみてください。

git config --global --add safe.directory *

参考