How does one make stable git scripts?

Git is a piece of software and it like all software it changes. Future versions of git might have better output coming out of a command.

So how does one write scripts using git that allow one to be secure that a new version of git will not break your script execution?

This is where the --pretty-format flag for GIT is really helpful. With this flag you can tightly control what information a GIT command will output so you can have confidence that your scripts will not be broken. The makers of GIT put this functionality into GIT for this purpose.

https://git-scm.com/docs/pretty-formats

See