それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

find コマンドでgit フォルダを無視したい(ただし.gitフォルダは表示したい

find コマンドで gitがズラッと並ぶの不便

ああ、、、、要らないよこんなの。。。

takuya@pages$ find
takuya@pages-sample$ $(which find ) -type f
./.git/COMMIT_EDITMSG
./.git/config
./.git/description
./.git/FETCH_HEAD
./.git/HEAD
./.git/index
./.git/info/exclude
./.git/logs/HEAD
./.git/logs/refs/heads/master
./.git/logs/refs/remotes/origin/master
./.git/objects/02/399e371c5d109e1c8221c74c9135a0c069d8fb
./.git/objects/07/968b16567a3c9b2eae0a3749eeb4f16d90d16c
./.git/objects/0d/e9c93edbe76efb6f0deedb1078746667460c0e
./.git/objects/0e/5e7135586f82d8b80f243e18c57443fca70b00

not マッチを使う。

find -mindepth 1 -not -iwholename *.git/*

not マッチをして .git を無視した例

takuya@pages-sample$ find
/Users/takuya/.bin/find -mindepth 1 -not -iwholename *.git/*
./.git
./.gitignore
./.gitlab-ci.yml
./public
./public/index.html
./README.md

object は要らないけど、hookやconfigは見たいんだ。

find の -not は重ねて書くと、or 条件で積み重ねてていく。 というか、マッチしたものを除外するので正確には、-not 条件を 足す感じ

find -mindepth 1  \
-not -iwholename *.git/objects* \
-not -iwholename *.git/logs* \
-not -iwholename *.git/refs* \
-not -iwholename *.git/*HEAD* \
-not -iwholename *.git/in*

適度に選ぶ。

ガッツリ.git 消しちゃうのも不便。

.gitignroe.git/config とか .gitlatb-ci.yml とかもあるので適度に必要なものだけを残して、見ても仕方ないものを消せる。

find に ignroe scm っていうオプションがアレばいいのにね。

関連記事

git 萌え本

わかばちゃんと学ぶ Git使い方入門〈GitHub、Bitbucket、SourceTree〉

わかばちゃんと学ぶ Git使い方入門〈GitHub、Bitbucket、SourceTree〉