Custom shortcode that shows current git branch / tag?

I’m doing some documentation. It would be nice if the generated HTML could have, in the footer or so, an indication of the version / branch / tag / etc of the document the user is looking at, something like:

<footer>Git branch: develop; last modified: 2019-12-04</footer>

A custom shortcode seems to be the way to go, but it would have to do some kind of exec or such to invoke git. There isn’t an example that I can find that shows how to do this or even whether it can be done. Can it?

1 Like

Check out

1 Like

Darn, I should have been able to find this, but somehow I did not. Thank you.

Did you figure out how to get the current branch, given that it’s not part of .GitHub ?