0
Hello,
I’m trying to write a code in Python to save a git log from a git repository to a file . txt in a different directory using the function subprocess.Popen()
. I know the command line syntax is:
git -C [diretorioGit] log --first-parent --pretty="%H" > [diretorio/arquivoDestino]
but when trying to do using the Python function:
subprocess.Popen(["git", "-C", "github_repos/ChainLink-Token", "log", "--first-parent", "--pretty="+ "%H", '>' ,"../../github_commits/ChainLink-Token_commits.txt"], stdout=subprocess.PIPE).communicate()
the following error appears:
fatal: ambiguous argument '>': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
someone would know the error?
Note: why the command line is working
Thank you in advance
Tries
'--pretty="%H"'
.– Augusto Vasques
Thanks for trying to help my friend, but it didn’t work
– Alan Rodrigues Chaves
If the command works interactively, surely the problem revolves around those quotation marks of %H, because the way it is in the question is clearly wrong (the quotation marks will not be part of the command invoked by Popen()).
– epx