.gitattributes
デフォルトでは、ルートディレクトリにファイルがなく、ファイルもないすべてのgitリポジトリを探したいと思います。.gitignore
私は以前に見つけたことがありますが、find . -type d '!' -exec test -e "{}/.gitignore" ';' -print
トップレベルのgitディレクトリだけでなく、すべてのディレクトリがリストされています。
私のディレクトリツリーは次のとおりです。
GitHub
├─ _Clones
| ├─ repo1 (has .gitignore)
| └─ repo2
├─ _Forks
| ├─ repo1 (has .gitattributes)
| └─ _For-Later
| ├─ repo2
| └─ repo3
├─ myrepo1 (has both)
├─ myrepo2 (has both)
...
└─ myrepo10
_Clones\repo2
このようなレイアウトでは、出力が、およびになりたいと思います。_Forks\_For-Later\repo2
_Forks\_For-Later\repo3
myrepo10
パラメータを使って探してみましたdepth
が、ディレクトリ別の変数です!
ベストアンサー1
gitリポジトリのルートディレクトリを一覧表示するには、次のコマンドを使用します。
find . -name .git -print0 | xargs -0 dirname
Variantは、以下を含むすべてのフォルダを探します.gitignore
。
find . -name .gitignore -print0 | xargs -0 dirname
ルートディレクトリに含まれていないgitリポジトリを確認するには、.gitignore
2つのフォルダセットを設定するだけです。
comm -23 <(find . -name .git -print0 | xargs -0 dirname | sort) <(find . -name .gitignore -print0 | xargs -0 dirname | sort)
これは、2つのフォルダセット(ソートする必要があります)を比較し、最初のセットにのみ表示されるフォルダを一覧表示します。仕事<()
はプロセスの交換そして、すべてのコマンドの出力をファイルの代わりに他のコマンドの入力として使用できます。
ルートディレクトリに含まれていないgitリポジトリを.gitignore
見つけるには、上記のように置き換えてください。.gitattributes
.gitattributes
希望の最終出力を得るには、次の2つを組み合わせます。
comm -23 <(comm -23 <(find . -name .git -print0 | xargs -0 dirname | sort) <(find . -name .gitignore -print0 | xargs -0 dirname | sort)) <(find . -name .gitattributes -print0 | xargs -0 dirname | sort)