From 6dfe9eaea9ef97043c74fe98367ee9ad283fc77d Mon Sep 17 00:00:00 2001 From: Neelesh19634 <143541329+Neelesh19634@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:46:02 +0530 Subject: [PATCH] added rm-gitignore script --- scripts/rm-gitignore | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/rm-gitignore b/scripts/rm-gitignore index 181f0ae..208ff2e 100755 --- a/scripts/rm-gitignore +++ b/scripts/rm-gitignore @@ -1,4 +1,9 @@ #!/usr/bin/env bash -# Removes all files written in .gitignore of any git repository (multiple) present inside current directory -# To find list of all git repos inside current directory you can use: "find . -name .git -type d -prune" + if [ -f .gitignore ]; then + while IFS= read -r pattern; do + echo "Removing files with matching pattern: $pattern" + git ls-files --cached --ignored --exclude-standard | grep "$pattern" | xargs -I {} rm -f {} + done < .gitignore + fi +