MATLAB: Saving git log number of the current commit in MATLAB

gitMATLAB

I wanted to save the current git commit hash of the code that I am currently running. Ideally, something like:
git_hash_string = get_current_git_hash()
dips(git_hash_string)
and then have it written to some file or displayed to the matlab command line. Is that possible?

Best Answer

To simply query using the git command via the OS:
[s,git_hash_string] = system('git rev-parse HEAD')
Not sure how this might play with Matlab's git stuff... I haven't touched that, but use git separately to manage several of my Matlab libraries. I assume the underlying git management is the same regardless of whether you initialized the repo in Matlab or outside of it.