Skip to content

Instantly share code, notes, and snippets.

@thorgeir93
Last active June 10, 2020 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thorgeir93/8de88bc831aeec24d8752934f16038ff to your computer and use it in GitHub Desktop.
Save thorgeir93/8de88bc831aeec24d8752934f16038ff to your computer and use it in GitHub Desktop.
Run git status on every git repository under the given directory. Useful to find uncommitted files on your server.
#!/bin/bash
# Run git status on every git repository under the given directory.
# (see also: https://gist.github.com/mzabriskie/6631607)
#
# USAGE: bash git_status_recursive.sh <DIRECTORY_PATH>
#
# EXAMPLE1: bash git_status_recursive.sh /home/thorgeir
# EXAMPLE2: bash git_status_recursive.sh .
#
# DATE: Wed Jun 10 18:15:35 UTC 2020
DIRECTORY_PATH=${1};
for path in $(find ${DIRECTORY_PATH} -type d -name ".git" 2>/dev/null); do
pushd $(dirname ${path}) > /dev/null;
(set -x; git status -s $PWD);
popd > /dev/null;
done
# Example output:
# + git status -s /home/thorgeir/github/thorgeir/linux_configs
# M st_terminal_config.h
# + git status -s /home/thorgeir/github/thorgeir/utils
# + git status -s /home/thorgeir/github/thorgeir/calendar_icelandic
# ?? cal_is/test_cal_is.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment