diff --git a/usd/GitRepository.py b/usd/GitRepository.py
index 391fccd..861bc59 100644
--- a/usd/GitRepository.py
+++ b/usd/GitRepository.py
@@ -448,9 +448,10 @@ class USDGitRepository:
commit_tree += ['-p', upload_parent_commit]
commit_env = copy.copy(self._env)
commit_env.update(self.get_commit_environment(tree_hash, spi, patch_overrides))
+ commit_msg_file = None
try:
- _, commit_msg_file = tempfile.mkstemp()
- with open(commit_msg_file, "wb") as fp:
+ with tempfile.NamedTemporaryFile(delete=False) as fp:
+ commit_msg_file = fp.name
fp.write(msg)
commit_tree += ['-F', commit_msg_file]
cp = run(commit_tree, env=commit_env)