From 312b4a6c99263609249f177fdba1ca65925f2149 Mon Sep 17 00:00:00 2001 From: zxcxz7 Date: Thu, 26 May 2016 17:37:51 +0900 Subject: [PATCH 1/3] Add list command --- README.md | 6 ++++++ tips.json | 3 +++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index c75ad48..dac0a86 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ * [Extract file from another branch.](https://github.com/git-tips/tips#extract-file-from-another-branch) * [List only the root and merge commits.](https://github.com/git-tips/tips#list-only-the-root-and-merge-commits) * [Merge previous two commits into one.](https://github.com/git-tips/tips#merge-previous-two-commits-into-one) +* [List of git repositories in multiple directories.](https://github.com/git-tips/tips#list-of-git-repositories-in-multiple-directories) @@ -695,5 +696,10 @@ git log --first-parent git rebase --interactive HEAD~2 ``` +## List of git repositories in multiple directories. +```sh +find /path1 /path2 /path3 -regex '.*\.git' -type d -print0 | xargs -0 -I {} dirname {} +``` + diff --git a/tips.json b/tips.json index df23a19..107cbe7 100644 --- a/tips.json +++ b/tips.json @@ -311,4 +311,7 @@ }, { "title": "Merge previous two commits into one.", "tip": "git rebase --interactive HEAD~2" +}, { + "title": "List of git repositories in multiple directories.", + "tip": "find /path1 /path2 /path3 -regex '.*\\.git' -type d -print0 | xargs -0 -I {} dirname {}" }] From 55e2d4fa75837e3e79b8639050c640998b209bc6 Mon Sep 17 00:00:00 2001 From: zxcxz7 Date: Thu, 26 May 2016 23:17:03 +0900 Subject: [PATCH 2/3] Update tip and add an alternative Update find command to exclude hidden directories. Add GNU find command --- README.md | 12 +++++++++++- tips.json | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dac0a86..4e30d1b 100644 --- a/README.md +++ b/README.md @@ -698,7 +698,17 @@ git rebase --interactive HEAD~2 ## List of git repositories in multiple directories. ```sh -find /path1 /path2 /path3 -regex '.*\.git' -type d -print0 | xargs -0 -I {} dirname {} +find -E ${targetdir} \( -regex '.*/\.git + -not -regex '.*/\..*/\.git + \) -type d -print0 | xargs -0 -I {} dirname {} +``` + + +__Alternatives:__ +```sh +find ${targetdir} -regextype posix-egrep \( -regex '.*/\.git + -not -regex '.*/\..*/\.git + \) -type d -print0 | xargs -0 -I {} dirname {} ``` diff --git a/tips.json b/tips.json index 107cbe7..6aa8bf7 100644 --- a/tips.json +++ b/tips.json @@ -313,5 +313,6 @@ "tip": "git rebase --interactive HEAD~2" }, { "title": "List of git repositories in multiple directories.", - "tip": "find /path1 /path2 /path3 -regex '.*\\.git' -type d -print0 | xargs -0 -I {} dirname {}" + "tip": "find -E ${targetdir} \\( -regex '.*/\\.git$' -not -regex '.*/\\..*/\\.git$' \\) -type d -print0 | xargs -0 -I {} dirname {}", + "alternatives": ["find ${targetdir} -regextype posix-egrep \\( -regex '.*/\\.git$' -not -regex '.*/\\..*/\\.git$' \\) -type d -print0 | xargs -0 -I {} dirname {}"] }] From 04323cc7be3c51af116c5dcfe66fd3d4faea2aca Mon Sep 17 00:00:00 2001 From: zxcxz7 Date: Thu, 26 May 2016 23:21:31 +0900 Subject: [PATCH 3/3] Correct paths --- README.md | 4 ++-- tips.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e30d1b..f2ac52b 100644 --- a/README.md +++ b/README.md @@ -698,7 +698,7 @@ git rebase --interactive HEAD~2 ## List of git repositories in multiple directories. ```sh -find -E ${targetdir} \( -regex '.*/\.git +find -E /path1 /path2 /path3 \( -regex '.*/\.git -not -regex '.*/\..*/\.git \) -type d -print0 | xargs -0 -I {} dirname {} ``` @@ -706,7 +706,7 @@ find -E ${targetdir} \( -regex '.*/\.git __Alternatives:__ ```sh -find ${targetdir} -regextype posix-egrep \( -regex '.*/\.git +find /path1 /path2 /path3 -regextype posix-egrep \( -regex '.*/\.git -not -regex '.*/\..*/\.git \) -type d -print0 | xargs -0 -I {} dirname {} ``` diff --git a/tips.json b/tips.json index 6aa8bf7..d9ed1d3 100644 --- a/tips.json +++ b/tips.json @@ -313,6 +313,6 @@ "tip": "git rebase --interactive HEAD~2" }, { "title": "List of git repositories in multiple directories.", - "tip": "find -E ${targetdir} \\( -regex '.*/\\.git$' -not -regex '.*/\\..*/\\.git$' \\) -type d -print0 | xargs -0 -I {} dirname {}", - "alternatives": ["find ${targetdir} -regextype posix-egrep \\( -regex '.*/\\.git$' -not -regex '.*/\\..*/\\.git$' \\) -type d -print0 | xargs -0 -I {} dirname {}"] + "tip": "find -E /path1 /path2 /path3 \\( -regex '.*/\\.git$' -not -regex '.*/\\..*/\\.git$' \\) -type d -print0 | xargs -0 -I {} dirname {}", + "alternatives": ["find /path1 /path2 /path3 -regextype posix-egrep \\( -regex '.*/\\.git$' -not -regex '.*/\\..*/\\.git$' \\) -type d -print0 | xargs -0 -I {} dirname {}"] }]