Ram Rachum Ram Rachum - 1 year ago 92
Git Question

Git: Check programmatically if anything is staged

For a Git script I'm writing, I'd like to have a programmatic way to check whether there is anything at all staged. i.e. I want a positive result if anything at all is staged, and negative if nothing is staged.

Bonus points: A way to programmatically check whether there is anything new in the working tree that can be staged.

Answer Source

You're looking for:

git diff --cached --quiet

(or replace --quiet with --exit-code if you still want output)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download