git filter-branchで行末を修正しようとしましたが、うまくいきませんでした質問する

git filter-branchで行末を修正しようとしましたが、うまくいきませんでした質問する

私は、git の Windows/Linux の行末問題に悩まされています。GitHub、MSysGit、その他の情報源によると、最善の解決策は、ローカル リポジトリを Linux スタイルの行末を使用するように設定し、core.autocrlfに設定することのようtrueです。残念ながら、これを早めに実行しなかったため、変更をプルするたびに行末が壊れてしまいます。

答えを見つけたと思ったここしかし、私にはうまく動作しません。Linux のコマンド ラインに関する知識は限られているので、このスクリプトの「xargs fromdos」行が何をするのかさえわかりません。そのようなファイルまたはディレクトリは存在しないというメッセージが表示され続け、既存のディレクトリを指定しても、権限がないと表示されます。

私はこれを Windows 上の MSysGit と Mac OS X ターミナル経由で試しました。

ベストアンサー1

これを修正する最も簡単な方法は、すべての行末を修正するコミットを 1 つ作成することです。変更されたファイルがないと仮定すると、次のように実行できます。

# From the root of your repository remove everything from the index
git rm --cached -r .

# Change the autocrlf setting of the repository (you may want 
#  to use true on windows):
git config core.autocrlf input

# Re-add all the deleted files to the index
# (You should get lots of messages like:
#   warning: CRLF will be replaced by LF in <file>.)
git diff --cached --name-only -z | xargs -0 git add

# Commit
git commit -m "Fixed crlf issue"

# If you're doing this on a Unix/Mac OSX clone then optionally remove
# the working tree and re-check everything out with the correct line endings.
git ls-files -z | xargs -0 rm
git checkout .

おすすめ記事