Skip to content
\n

Result:

\n
repo.git.execute(f\"git commit -m 'word1 word2'\")\nTraceback (most recent call last):\n  File \"E:\\Program Files\\JetBrains\\PyCharm 2021.2.2\\plugins\\python\\helpers\\pydev\\_pydevd_bundle\\pydevd_exec2.py\", line 3, in Exec\n    exec(exp, global_vars, local_vars)\n  File \"<input>\", line 1, in <module>\n  File \"<homefolder>\\Repository\\iac\\infra-netbox-updates\\update-vlans-from-imc\\venv\\lib\\site-packages\\git\\cmd.py\", line 928, in execute\n    raise GitCommandError(redacted_command, status, stderr_value, stdout_value)\ngit.exc.GitCommandError: Cmd('g') failed due to: exit code(1)\n  cmdline: g i t   c o m m i t   - m   ' w o r d 1   w o r d 2 '\n  stderr: 'error: pathspec 'word2'' did not match any file(s) known to git'\n
\n

without the space it works

\n
repo.git.execute(f\"git commit -m 'word1_word2'\")\n\"[master 0dd6731] 'word1_word2'\\n 12 files changed, 6533 insertions(+)\\n create mode 100644 newfile.txt\n\n<information redacted>\n...\n
\n

I tried to use
\nrepo.commit('master')
\nand it works also , but i am clueless on how to place a message in this wrappers ..

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

Despite the name, execute() (instead of _execute() is a low-level method that shouldn't be used.

\n

Turn…

\n\n

…and things should work as expected.

\n

More about how to call git directly is in the docs.

","upvoteCount":1,"url":"https://github.com/gitpython-developers/GitPython/discussions/1379#discussioncomment-1697158"}}}

git.execute('commit -m "word1 word2') fails #1379

Answered by Byron
jcralbino asked this question in Q&A
Discussion options

You must be logged in to vote

Despite the name, execute() (instead of _execute() is a low-level method that shouldn't be used.

Turn…

  • repo.git.execute(f"git add {origin}*") into repo.git.add(f"{origin}*")
  • repo.git.execute(f"git commit -m 'word1 word2'") into repo.git.commit(m='word1 word2')

…and things should work as expected.

More about how to call git directly is in the docs.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jcralbino
Comment options

Answer selected by jcralbino
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants