git-diff in another directory
- by ABach
I'm currently writing a little zsh function that checks all of my git repositories to see if they're dirty or not and then prints out the ones that need a commit. Thus far, I've figured out that the quickest way to figure out a git repository's clean/dirty status is via git-diff and git-ls-files:
if ! git diff --quiet || git ls-files --others --exclude-standard; then
state=":dirty"
fi
I have two questions for you folks:
Does anyone know of a quicker, more efficient way to check for file changes/additions in a git repo?
I want my zsh function to be handed a file path (say ~/Code/git-repos/) and check all of the repositories in it. Is there a way to do without having to cd into each directory and run those commands? Something like git-diff --quiet --git-dir="~/Code/git-repos/..." would be fantastic.
Thanks! :)