Git -diff in a different directory
I am currently writing a small zsh function that checks all my git repos to see if they are dirty or not and then prints out the ones that need to be committed. So far, I've figured out that the fastest way to determine the git state of a clean / dirty repository is through 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:
- Does anyone know of a faster and more efficient way to check for file changes / additions in a git repository
- I want my zsh function to pass a file path (say
~/Code/git-repos/
) and check all repositories. Is there a way to get by without using cd in each directory and run those commands? Something likegit-diff --quiet --git-dir="~/Code/git-repos/..."
it would be fantastic.
Thanks!:)
+2
a source to share