Skip to content

Instantly share code, notes, and snippets.

@farrellit
Created December 13, 2017 23:32
Show Gist options
  • Save farrellit/8cc1c16449ee04170103a73bec1c85d1 to your computer and use it in GitHub Desktop.
Save farrellit/8cc1c16449ee04170103a73bec1c85d1 to your computer and use it in GitHub Desktop.
find repos without local changes
# find directories containing .git subdirs
find ~/ -type d -name '.git' -print0 | xargs -n 1 -0 dirname \
| xargs -I % -n 1 bash -c 'cd "%" && pwd 1>&2; (git status --porcelain| grep -q . && [[ ! -n "`git diff`" ]] ) || echo %'\
| xargs -I % bash -c '[[ -n "`cd %; git status --porcelain; git diff;`" ]] && echo %' \
| tee /dev/stderr | sort > purportedly-empty-repos.txt
#That makes sure you don't have any uncommitted changes. But it still doesn't check to make sure you don't have unpushed commits.
@farrellit
Copy link
Author

farrellit commented Dec 13, 2017

iterating through each repo's branches to check against an upstream in bash? Maybe doable easily enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment