git-diff in another directory

Posted by ABach on Stack Overflow See other posts from Stack Overflow or by ABach
Published on 2010-05-05T19:09:07Z Indexed on 2010/05/05 19:38 UTC
Read the original article Hit count: 278

Filed under:
|

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:

  1. Does anyone know of a quicker, more efficient way to check for file changes/additions in a git repo?
  2. 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! :)

© Stack Overflow or respective owner

Related posts about git

Related posts about zsh