
[英]Cloning a git repo from git bash using python script from command prompt failing. Why?
[英]Automate config command in Git Bash with Python
我想自动执行这些命令:
echo something
git config --global user.name "myUser"
git config --global user.email "myMail@mail.com"
我做了一些研究,在 Python subprocess
中看到了这个库。 但是以下命令不起作用:
import subprocess
subprocess.call(["echo", "something"])
subprocess.call(["git", "config", "--global", "user.name", "\"myUser\""])
subprocess.call(["git", "config", "--global", "user.email", "myMail@mail.com"])
这是我的“.bat”文件,其中有 Python 位置和脚本位置:
@echo off
"C:\Python27\python.exe" -c "D:\Tools\Scripts\GIT_login.py"
pause
不幸的是,当我运行“.bat”文件时,我收到以下消息:
File "<string>", line 1
D:\Tools\Scripts\GIT_login.py
↑
SyntaxError: invalid syntax
如果您在 git-bash 上运行 bat,则需要像这样提供 python 文件路径:'D://Tools/Scripts/GIT_login.py'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.