Created
February 9, 2021 02:34
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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