{"id":8180,"date":"2024-04-24T23:33:59","date_gmt":"2024-04-24T14:33:59","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=8180"},"modified":"2024-04-24T23:56:51","modified_gmt":"2024-04-24T14:56:51","slug":"%ef%bc%88git-%e3%81%ae%ef%bc%89%e3%83%aa%e3%83%9d%e3%82%b8%e3%83%88%e3%83%aa%e5%86%85%e3%81%ae%e6%94%b9%e8%a1%8c%e3%82%b3%e3%83%bc%e3%83%89%e3%82%92-crlf-%e3%81%8b%e3%82%89-lf-%e3%81%ab%e3%81%99","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=8180","title":{"rendered":"\uff08git \u306e\uff09\u30ea\u30dd\u30b8\u30c8\u30ea\u5185\u306e\u6539\u884c\u30b3\u30fc\u30c9\u3092 CRLF \u304b\u3089 LF \u306b\u3059\u308b"},"content":{"rendered":"<p>\u624b\u5143 git \u30ea\u30dd\u30b8\u30c8\u30ea\u306f\u6b74\u53f2\u7684\u7d4c\u7def\u306b\u3088\u308a\u6539\u884c\u30b3\u30fc\u30c9\u304c\u5185\u90e8\u3067\u3082 CRLF \u306b\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u3082\u306e\u304c\u305f\u304f\u3055\u3093\u3042\u308b\u3093\u3067\u3059\u304c\u3001\u305d\u308c\u3092 LF \u306b\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u307e\u305a\u5c02\u7528\u306e\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b clone \u3057\u307e\u3059\u3002<\/p>\n<blockquote>\n<pre>\r\n~$ git clone ...\/example.git\r\n~$ cd example\r\n~\/example$\r\n<\/pre>\n<\/blockquote>\n<p>git \u306e\u8a2d\u5b9a\u306e <code>core.autocrlf<\/code> \u304c <code>false<\/code> \u306b\u306a\u3063\u3066\u3044\u308bor\u5168\u304f\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\u304c <code>false<\/code> \u306a\u306e\u3067\uff09\u74b0\u5883\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u4f8b\u3048\u3070\u666e\u901a\u306e Linux (Unix) \u74b0\u5883\u3067\u3059\u3002WSL \u74b0\u5883\u306f\u77e5\u3089\u306a\u3044\u3002<\/p>\n<blockquote>\n<pre>\r\n~\/example$ git config -l | grep core.autocrlf\r\n~\/example$\r\n<\/pre>\n<\/blockquote>\n<p>\uff08\u4f55\u3082\u51fa\u3066\u3053\u306a\u3044 = \u30c7\u30d5\u30a9\u30eb\u30c8 = <code>false<\/code>\uff09<\/p>\n<p><code>input<\/code> \u3084 <code>true<\/code> \u306b\u306a\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u3001<code>false<\/code> \u306b\u3057\u3066\u304b\u3089\u30d5\u30a1\u30a4\u30eb\u3092\u4e00\u65e6\u524a\u9664\u3057\u3066 checkout \u3057\u306a\u304a\u3057\u307e\u3059\u3002<\/p>\n<blockquote>\n<pre>\r\n~\/example$ git config --local core.autocrlf false\r\n~\/example$ find . -mindepth 1 -maxdepth 1 -not -path '.\/.git'  # \u610f\u56f3\u3057\u306a\u3044\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3057\u306a\u3044\u304b\u78ba\u8a8d\r\n~\/example$ find . -mindepth 1 -maxdepth 1 -not -path '.\/.git' -print0 | xargs -0 rm -rf  # \u4e00\u65e6\u524a\u9664\r\n~\/example$ git reset --hard HEAD  # \u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u5fa9\u5143\r\n~\/example$\r\n<\/pre>\n<\/blockquote>\n<p>CRLF \u306a\u30d5\u30a1\u30a4\u30eb\u3092\u78ba\u8a8d\u3057\u3066 LF \u306b\u5909\u63db\u3057\u307e\u3059\u3002<\/p>\n<blockquote>\n<pre>\r\n~\/example$ find . -type f -not -path '.\/.git\/**'  # \u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u306e\u78ba\u8a8d\r\n~\/example$ find . -type f -not -path '.\/.git\/**' -print0 | xargs -0 file | grep CRLF  # CRLF \u306a\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u78ba\u8a8d\r\n~\/example$ find . -type f -not -path '.\/.git\/**' -print0 | xargs -0 file | grep CRLF | awk -F: '{print $1}'  # \u30d5\u30a1\u30a4\u30eb\u540d\u3060\u3051\u5207\u308a\u51fa\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\r\n~\/example$ find . -type f -not -path '.\/.git\/**' -print0 | xargs -0 file | grep CRLF | awk -F: '{print $1}' | xargs -n1 perl -i -pe 's\/\\r\\n\/\\n\/'  # \u5b9f\u969b\u306b\u5909\u63db\r\n~\/example$ find . -type f -not -path '.\/.git\/**' -print0 | xargs -0 file | grep CRLF  # \u51fa\u3066\u3053\u306a\u3044 = \u5168\u90e8\u5909\u63db\u3055\u308c\u305f\u3053\u3068\u3092\u78ba\u8a8d\r\n~\/example$ git diff | less -R  # less \u306e\u5b9f\u88c5\u306b\u3088\u3063\u3066\u306f CR \u304c\u6d88\u3048\u3066\u3044\u308b\u3053\u3068\u3092\u8868\u793a\u3067\u304d\u308b\r\n<\/pre>\n<\/blockquote>\n<p>\u30d5\u30a1\u30a4\u30eb\u306e\u78ba\u8a8d\u6642\u306b\u30b3\u30ed\u30f3\u3092\u542b\u3080\u30d5\u30a1\u30a4\u30eb\u540d\u304c\u3042\u3063\u305f\u308a\u4f59\u8a08\u306a\u30d5\u30a1\u30a4\u30eb\u304c\u51fa\u3066\u6765\u305f\u308a\u3059\u308b\u5834\u5408\u306f\u9069\u5f53\u306b\u304c\u3093\u3070\u308a\u307e\u3057\u3087\u3046\u3002<br \/>\n\uff08CRLF \u306b\u306a\u3063\u3066\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u666e\u901a\u306f Windows \u3067\u7de8\u96c6\u3057\u305f\u3053\u3068\u306e\u3042\u308b\u30d5\u30a1\u30a4\u30eb\u306e\u306f\u305a\u306a\u306e\u3067\u30b3\u30ed\u30f3\u3092\u542b\u3080\u3053\u3068\u306f\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u304c\uff09<\/p>\n<p>\u3067\u3082\u3063\u3066 commit &amp; push<\/p>\n<blockquote>\n<pre>\r\n~\/example$ git commit -a -m 'convert CRLF to LF'\r\n~\/example$ git push\r\n<\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u624b\u5143 git \u30ea\u30dd\u30b8\u30c8\u30ea\u306f\u6b74\u53f2\u7684\u7d4c\u7def\u306b\u3088\u308a\u6539\u884c\u30b3\u30fc\u30c9\u304c\u5185\u90e8\u3067\u3082 CRLF \u306b\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u3082\u306e\u304c\u305f\u304f\u3055\u3093\u3042\u308b\u3093\u3067\u3059\u304c\u3001\u305d\u308c\u3092 LF \u306b\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-8180","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/8180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8180"}],"version-history":[{"count":4,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/8180\/revisions"}],"predecessor-version":[{"id":8184,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/8180\/revisions\/8184"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8180"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}