Skip to content

Instantly share code, notes, and snippets.

@anil3a
Created February 9, 2021 02:34
Show Gist options
  • Save anil3a/c88caff3840e7079739c81a4eeb89ded to your computer and use it in GitHub Desktop.
Save anil3a/c88caff3840e7079739c81a4eeb89ded to your computer and use it in GitHub Desktop.
Linux or Mac Bash script that checks GIT folders inside one parent folder to get git status for file changes and git branch name
#!/bin/bash
### Usage
### gitchecker.sh Parent_Folder_With_GIT_Folders
DIR=$(PWD)/$1
for R in $DIR/*; do
cd $R
if `git status | grep -q "nothing to commit"`;
then
#echo $R "no changes"
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
folder=$(basename $R)
printf '%-30s %-30s\n' $folder $branch
continue
else
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
folder=$(basename $R)
printf '%-30s %-30s %-30s\n' $folder $branch "has changes"
#echo $(basename $R) " has changes"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment