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.