Skip to content

Instantly share code, notes, and snippets.

@stefanofiorentino
Last active May 4, 2020 10:39
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 stefanofiorentino/17a97904a50b8d5a51885e748024d737 to your computer and use it in GitHub Desktop.
Save stefanofiorentino/17a97904a50b8d5a51885e748024d737 to your computer and use it in GitHub Desktop.
git script to add to $PATH to get all sub-directories' repository commit sha
#!/bin/bash
GIT_REPOS_HOME=$PWD \
find . -type d -name '.git*' ! -path "*/poky-tmp/*" 2>/dev/null | \
sed 's/\.git$//g' | \
xargs -I '{}' sh -c 'readlink -e {};' | \
uniq | \
sort | \
xargs -I '{}' sh -c 'cd {}; echo "dir: $(pwd) url: $(git config --get remote.origin.url) branch: $(git rev-parse --abbrev-ref HEAD) hash: $(git rev-parse HEAD)"; cd $GIT_REPOS_HOME;'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment