Skip to content

Instantly share code, notes, and snippets.

@ahgraber
Created March 1, 2023 14:17
Show Gist options
  • Save ahgraber/4b2dd01a32d030ab7154098cf39ed037 to your computer and use it in GitHub Desktop.
Save ahgraber/4b2dd01a32d030ab7154098cf39ed037 to your computer and use it in GitHub Desktop.
Get lines of code across multiple repos
#!/bin/bash
## assumes "multiple repos" are all in the same parent directory, which is also the current working directory
# set up git
for dir in ./*/; do
dir=${dir%*/} # remove the trailing "/"
cd "$dir"
echo "$dir"
git fetch -p && git pull
# select branch if required
# git branch ...
cd ..
done
# get counts of files & lines
for dir in ./*/; do
dir=${dir%*/} # remove the trailing "/"
cd "$dir"
echo "$dir"
git diff --shortstat "$(git hash-object -t tree /dev/null)"
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment