Encode the message into utf-8 before passing to git

(cherry picked from commit 5ab7ee0df8cc0136070f17d329a8c54a144642c5)