LoginSignup
8
8

More than 5 years have passed since last update.

.gitattributesを作る際の参考情報を出力するコマンド

Posted at

途中で入ったプロジェクトなんで、どんなファイルがあるかわかりゃしない。

プロジェクトのソースはGitで管理されているけど、.gitattributesファイルが無いので、CRLFが入り乱れている。

.gitattributesを置くことでせめてテキストファイルの改行くらいは何とかしたい。

そんなときに打つべきコマンド。

find . -type f | grep -v ".git/" | xargs -Ixx file -i -N xx | sed -e 's/.\+\([\/\.][^\/^\.]\+\+\):/\1/g' |sort -u > .gitattributes

これで一応、すべてのファイルの種類が.gitattributesに格納される。

もちろんそのままではだめなので、これを手で修正する必要があるが、結構助かると思う。

ちなみに、全ファイルをfileコマンドで調査するのでちょっと重い。。。

.javaとか画像とかのファイルのタイプが明らかなものは削ってもいいんじゃないかなぁ。

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8