Last active
August 29, 2015 13:57
-
-
Save tristanlins/9504609 to your computer and use it in GitHub Desktop.
Script to find GIT repositories that have modified files and unpublished commits.
This file contains hidden or 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 | |
BASEDIR=$(pwd) | |
find -type d -name .git | while read GITDIR; do | |
DIR=$(dirname $GITDIR) | |
cd "$BASEDIR/$DIR" | |
STATUS=$(git status -s) | |
if [[ -n "$STATUS" ]]; then | |
echo '--- modifications --------------------------------------------------------------' | |
pwd | |
echo | |
git status -s | |
echo | |
fi | |
LOCAL_BRANCH=$(git symbolic-ref HEAD 2>/dev/null) | |
LOCAL_BRANCH=${LOCAL_BRANCH#refs/heads/} | |
if [[ -n "$LOCAL_BRANCH" ]]; then | |
REMOTE=$(git config branch.$LOCAL_BRANCH.remote) | |
REMOTE_BRANCH=$(git config branch.$LOCAL_BRANCH.merge) | |
REMOTE_BRANCH=${REMOTE_BRANCH#refs/heads/} | |
if [[ -n "$REMOTE" ]]; then | |
git fetch --quiet "$REMOTE" | |
LOG=$(git --no-pager log --oneline "$REMOTE/$REMOTE_BRANCH..$LOCAL_BRANCH") | |
if [[ -n "$LOG" ]]; then | |
echo '--- unpublished commits --------------------------------------------------------' | |
pwd | |
echo | |
git --no-pager log --oneline "$REMOTE/$REMOTE_BRANCH..$LOCAL_BRANCH" | |
echo | |
fi | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment