hiiragi's ブログ

主にコンピュータ関係の備忘録を書いてます

git cloneした時にautocrlfで変換された改行コードを元に戻す方法

WindowsのGitでgit config --system core.autocrlfがtrueになっていることがあってハマったのでメモ。

手っ取り早い方法

1. autocrlfの設定を変更

git config --global core.autocrlf false

2. 再度クローン

再度クローンしたくない場合の方法

1. 全ファイルを消す
(本当はGitで管理しているファイルのみ削除したいけど方法を知りません...)

rm -rf *
ls -a
. .. .git .gitignore .travis.yml
rm .gitignore
rm .travis.yml

2. autocrlfの設定を変更

git config --global core.autocrlf false

3. チェックアウト

git checkout .


2017/2/10 追記

クローンしない方法

git config core.autocrlf true
git rm --cached -r .
git reset --hard
git add .
git commit -m "change: lf -> crlf"
git config core.autocrlf false


参考