{"id":5480,"date":"2022-07-12T09:00:03","date_gmt":"2022-07-12T00:00:03","guid":{"rendered":"https:\/\/www.chihayafuru.jp\/tech\/?p=5480"},"modified":"2022-12-20T10:44:27","modified_gmt":"2022-12-20T01:44:27","slug":"git-wsl%e3%81%ae%e3%83%87%e3%82%a3%e3%83%ac%e3%82%af%e3%83%88%e3%83%aa%e3%82%92sourcetree%e3%81%8b%e3%82%89%e9%96%8b%e3%81%8f","status":"publish","type":"post","link":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/archives\/5480","title":{"rendered":"[git] fatal: unsafe repository"},"content":{"rendered":"<h3>1. unsafe repository \u30a8\u30e9\u30fc\u306e\u901a\u77e5\u4f8b<\/h3>\n<h4>1.1. \u5916\u90e8\u30b9\u30c8\u30ec\u30fc\u30b8\u306b\u7f6e\u304b\u308c\u305f\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30a2\u30af\u30bb\u30b9<\/h4>\n<pre class=\"lang:default highlight:0 decode:true \" >&gt; cd E:\\USO_800\r\n> git status\r\nfatal: unsafe repository ('E:\/USO_800' is owned by someone else)\r\nTo add an exception for this directory, call:\r\n\r\n        git config --global --add safe.directory E:\/USO_800<\/pre>\n<h4>1.2. WSL(Windows Subsystem for Linux)\u5185\u306b\u3042\u308b\u4eee\u60f3\u30c9\u30e9\u30a4\u30d6\u306e\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30a2\u30af\u30bb\u30b9<\/h4>\n<pre class=\"lang:default highlight:0 decode:true \" >'git status' \u304c\u30b3\u30fc\u30c9 128 \u3067\u7d42\u4e86\u3057\u307e\u3057\u305f: fatal unsafe repository ('\/\/wsl$\/Ubuntu\/home\/...')<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/chihayafuru.s3-ap-northeast-1.amazonaws.com\/imgs\/wp\/2022\/07\/git_fatal_unsafe_repository.png\" alt=\"SourceTree fatal unsafe repository\"><\/p>\n<h4>1.3. \u81ea\u5206\u4ee5\u5916\u306bOwnership\u304c\u3042\u308b\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u7f6e\u304b\u308c\u305f\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30a2\u30af\u30bb\u30b9<\/h4>\n<pre class=\"lang:default highlight:0 decode:true \">$ git status\r\nfatal: unsafe repository ('\/var\/www' is owned by someone else)\r\nTo add an exception for this directory, call:\r\n\r\n\tgit config --global --add safe.directory \/var\/www<\/pre>\n<p><!--more--><\/p>\n<p>&nbsp;<\/p>\n<h3>2. unsafe repository \u30a8\u30e9\u30fc\u306e\u539f\u56e0<\/h3>\n<p>git \u306e\u8106\u5f31\u6027\u5bfe\u7b56\u3002<br \/>\u60aa\u610f\u3092\u6301\u3063\u305f\u7b2c\u4e09\u8005\u304c<strong>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u5171\u6709\u30c9\u30e9\u30a4\u30d6<\/strong>\u3084<strong>\u5916\u90e8\u30b9\u30c8\u30ec\u30fc\u30b8<\/strong>\uff08USB\u30e1\u30e2\u30ea\u306a\u3069\uff09\u306a\u3069\u306b\u7f6e\u304b\u308c\u305f <strong>\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea ( .git\u30d5\u30a9\u30eb\u30c0 )<\/strong> \u3092\u6539\u7ac4\u3057\u3066\u3001git\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306b\u4efb\u610f\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3055\u305b\u308b\u8106\u5f31\u6027\u304c\u767a\u898b\u3055\u308c\u305f\u3002\u305d\u3053\u3067\u7b2c\u4e09\u8005\u306b\u3088\u308b\u6539\u7ac4\u53ef\u80fd\u306a\u30d5\u30a9\u30eb\u30c0\u306b\u7f6e\u304b\u308c\u305f <strong>.git\u30d5\u30a9\u30eb\u30c0<\/strong> \u3092\u4e0d\u7528\u610f\u306b\u958b\u3044\u3066\u3057\u307e\u308f\u306a\u3044\u3088\u3046\u306b\u5236\u9650\u304c\u304b\u3051\u3089\u308c\u305f\u3002git\u306e\u8a2d\u5b9a(git config)\u3067\u660e\u793a\u7684\u306b\u6307\u5b9a\u3055\u308c\u305f\u5b89\u5168\u306a <strong>.git\u30d5\u30a9\u30eb\u30c0<\/strong> \u306b\u9650\u308a\u958b\u304f\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>3. unsafe repository \u30a8\u30e9\u30fc\u306e\u767a\u751f\u6761\u4ef6<\/h3>\n<ul>\n<li>\u300e<strong>\u5916\u90e8\u30b9\u30c8\u30ec\u30fc\u30b8<\/strong>\uff08USB\u30e1\u30e2\u30ea\u306a\u3069\uff09\u300f\u306b\u7f6e\u304b\u308c\u305f <strong>.git\u30d5\u30a9\u30eb\u30c0<\/strong> \uff08\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\uff09\u3092\u542b\u3080\u30ef\u30fc\u30af\u30d5\u30a9\u30eb\u30c0\u306bgit\u30b3\u30de\u30f3\u30c9\u3067\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3057\u305f\u3002<\/li>\n<li>\u300e<strong>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30c9\u30e9\u30a4\u30d6<\/strong>\u300f\u306b\u7f6e\u304b\u308c\u305f <strong>.git\u30d5\u30a9\u30eb\u30c0<\/strong> \u3092\u542b\u3080\u30ef\u30fc\u30af\u30d5\u30a9\u30eb\u30c0\u306bgit\u30b3\u30de\u30f3\u30c9\u3067\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3057\u305f\u3002<\/li>\n<li>Windows\u30a2\u30d7\u30ea\uff08\u305f\u3068\u3048\u3070 SourceTree\uff09\u304b\u3089\u300e<strong>\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30c9\u30e9\u30a4\u30d6<\/strong> (<code>\\\\wsl$<\/code>) \u7d4c\u7531\u300f\u3067WSL(Windows Subsystem for Linux)\u306e\u4e2d\u306e <strong>.git\u30d5\u30a9\u30eb\u30c0<\/strong> \u3092\u542b\u3080\u30ef\u30fc\u30af\u30d5\u30a9\u30eb\u30c0\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3057\u305f\u3002<\/li>\n<li>UNIX\u7cfbOS\u306b\u304a\u3044\u3066\u3001\u81ea\u5206\u4ee5\u5916\u306bownership\u304c\u3042\u308b\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3057\u305f\u3002<\/li>\n<ul>\n<p>&nbsp;<\/p>\n<h3>4. unsafe repository \u30a8\u30e9\u30fc\u306e\u89e3\u6c7a\u65b9\u6cd5<\/h3>\n<h4>4.1. \u30d9\u30b9\u30c8\u306a\u89e3\u6c7a\u65b9\u6cd5\uff1a\u7b2c\u4e09\u8005\u304c\u6539\u7ac4\u3067\u304d\u308b\u5834\u6240\u306b .git\u30d5\u30a9\u30eb\u30c0 \u3092\u7f6e\u304b\u306a\u3044<\/h4>\n<ul>\n<li>\u7b2c\u4e09\u8005\u304c\u6539\u7ac4\u3067\u304d\u308b\u5834\u6240\u306b <strong>.git\u30d5\u30a9\u30eb\u30c0<\/strong> \u3092\u7f6e\u304b\u306a\u3044\u3002<\/li>\n<li>\u7b2c\u4e09\u8005\u304c\u6539\u7ac4\u3067\u304d\u306a\u3044\u5834\u6240\u306b <strong>.git\u30d5\u30a9\u30eb\u30c0<\/strong> \u3092\u79fb\u52d5\uff0f\u8907\u88fd\u3059\u308b\u3002\n<ul>\n<li>\u305f\u3060\u3057\u3001\u79fb\u52d5\uff0f\u8907\u88fd\u306e\u524d\u306b\u6539\u7ac4\u3055\u308c\u3066\u3044\u308c\u3070\u3001git\u306e\u8106\u5f31\u6027\u3092\u7a81\u7834\u3055\u308c\u308b\u30ea\u30b9\u30af\u304c\u3042\u308b\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>4.2. \u30d9\u30bf\u30fc\u306a\u89e3\u6c7a\u65b9\u6cd5\uff1a\u5b89\u5168\u306a\u30d5\u30a9\u30eb\u30c0\uff08\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\uff09\u3068\u3057\u3066\u8a2d\u5b9a\u3059\u308b<\/h4>\n<p>\u305f\u3068\u3048\u3070\u3001WSL (Windows Subsystem for Linux) \u306e\u4e2d\u306e\u30d5\u30a9\u30eb\u30c0\u3092\u79fb\u52d5\u3059\u308b\u3053\u3068\u306f\u73fe\u5b9f\u7684\u3067\u306f\u306a\u304f\u3001\u7b2c\u4e09\u8005\u306b\u3088\u308b\u6539\u7ac4\u30ea\u30b9\u30af\u306f\u5c0f\u3055\u3044\u305f\u3081\u3001\u500b\u5225\u306b\u5b89\u5168\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea safe.directory \u3068\u3057\u3066\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067 git\u30b3\u30de\u30f3\u30c9\u306e\u30a2\u30af\u30bb\u30b9\u5236\u9650\u3092\u56de\u907f\u3067\u304d\u307e\u3059\u3002<\/p>\n<h5>4.2.1. git config\u30b3\u30de\u30f3\u30c9\u3067\u8a2d\u5b9a\u3059\u308b<\/h5>\n<pre class=\"lang:default highlight:0 decode:true \" >git config --global --add safe.directory '%(prefix)\/\/\/wsl$\/Ubuntu\/home\/your_name\/your_project'<\/pre>\n<h5>4.2.2. .config\u3092\u76f4\u63a5\u7de8\u96c6\u3059\u308b<\/h5>\n<pre class=\"lang:default highlight:0 decode:true \" ># .gitconfig\r\n[safe]\r\n    directory %(prefix)\/\/\/wsl$\/Ubuntu\/home\/your_name\/your_project<\/pre>\n<p>&nbsp;<\/p>\n<h3>\u53c2\u8003\u30ea\u30f3\u30af<\/h3>\n<ul>\n<li><a href=\"https:\/\/github.blog\/2022-04-12-git-security-vulnerability-announced\/\">Git security vulnerability announced<\/a>\n<li><a href=\"https:\/\/jira.atlassian.com\/browse\/SRCTREEWIN-10956\">A fix in Git version 2.35.2 causes errors in WSL paths.<\/a><\/li>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1. unsafe repository \u30a8\u30e9\u30fc\u306e\u901a\u77e5\u4f8b 1.1. \u5916\u90e8\u30b9\u30c8\u30ec\u30fc\u30b8\u306b\u7f6e\u304b\u308c\u305f\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30a2\u30af\u30bb\u30b9 &gt; cd E:\\USO_800 > git status fatal: unsafe rep [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[2],"class_list":["post-5480","post","type-post","status-publish","format-standard","hentry","category-memo","tag-git"],"_links":{"self":[{"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/posts\/5480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/comments?post=5480"}],"version-history":[{"count":42,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/posts\/5480\/revisions"}],"predecessor-version":[{"id":5868,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/posts\/5480\/revisions\/5868"}],"wp:attachment":[{"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/media?parent=5480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/categories?post=5480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/tags?post=5480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}