Skip to content

Instantly share code, notes, and snippets.

@sstadelman
Last active February 26, 2020 21:40
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 sstadelman/9d94cb6d600745480440f7760fd31f02 to your computer and use it in GitHub Desktop.
Save sstadelman/9d94cb6d600745480440f7760fd31f02 to your computer and use it in GitHub Desktop.
Check status of nested repositories
for f in *; do
if [ -d ${f} ]; then
cd $(echo $f)
echo $(pwd)
for g in *; do
if [ -d ${g} ]; then
# Will not run if no directories are available
cd $(echo $g)
echo $(pwd) >> ../../git-check-status-output.txt
git status >> ../../git-check-status-output.txt
echo $'\n' >> ../../git-check-status-output.txt
cd ".."
fi
done
cd ".."
fi
done
# For migrating directories of git repositories to new machine
# Run in root of a directory containing subdirectories for each
# git account or organization (e.g. github/, or wdfgithub/)
#
# E.g.
# github/ # this is a container directory
# sstadelman/ # this is an account
# observable-array/ # this is a repository
# objcio/
#
# Outputs a script named git-get-remote-urls-output.sh which should
# be copied to the new machine, and executed in the container directory
rm git-get-remote-urls-output.sh
for f in *; do
if [ -d ${f} ]; then
cd $(echo $f)
# echo $(pwd)
working_dir=${PWD##*/}
echo "mkdir -p ${working_dir}" >> ../git-get-remote-urls-output.sh
echo "cd ${working_dir}" >> ../git-get-remote-urls-output.sh
for g in *; do
if [ -d ${g} ]; then
# Will not run if no directories are available
cd $(echo $g)
echo $(pwd) >> git-get-remote-urls-output.txt
remote_url=$(git config --get remote.origin.url)
if [ -z "$remote_url" ]; then
echo "no repo in ${pwd}"
else
echo "git clone ${remote_url}" >> ../../git-get-remote-urls-output.sh
echo $'\n' >> git-get-remote-urls-output.txt
fi
cd ".."
fi
done
echo "cd .." >> ../git-get-remote-urls-output.sh
cd ".."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment