Programmatically printing git revision and checking for uncommitted changes

Posted by Andrew Grimm on Stack Overflow See other posts from Stack Overflow or by Andrew Grimm
Published on 2010-04-29T01:57:36Z Indexed on 2010/04/29 2:07 UTC
Read the original article Hit count: 342

Filed under:

To ensure that my scientific analysis is reproducible, I'd like to programmatically check if there are any modifications to the code base that aren't checked in, and if not, print out what commit is being used.

For example, if there are uncommitted changes, it should output

Warning: uncommitted changes made. This output may not be reproducible.

Else, produce

Current commit: d27ec73cf2f1df89cbccd41494f579e066bad6fe

Ideally, it should use "plumbing", not "porcelain".

© Stack Overflow or respective owner

Related posts about git