Skip to content

Instantly share code, notes, and snippets.

@harrygallagher4
Last active October 13, 2019 19:07
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 harrygallagher4/9b3b82664592c3b40e262da40c0ad7f2 to your computer and use it in GitHub Desktop.
Save harrygallagher4/9b3b82664592c3b40e262da40c0ad7f2 to your computer and use it in GitHub Desktop.
bash one-liner to pull all git repositories in the current directory
# most of this is sourced from stackoverflow answers
# git diff checks if the current directory is clean
# git remote checks if there is even a remote repo to pull from
ls | xargs -I{} sh -c '[[ -d {}/.git ]] && [[ $(git -C {} diff --shortstat 2> /dev/null | tail -n1) == "" ]] && [[ $(git -C {} remote) != "" ]] && echo {}: && git -C {} pull'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment