我必须拿出Python脚本来捕获GIT的所有更改。此脚本将自动运行一天一次。你知道吗
我已经想出了这个办法,但看起来并不令人满意。你知道吗
import os
import subprocess
from subprocess import *
accpath = 'M:/STD1/GIT_TEST'
print (accpath)
subprocess.Popen(["ls"],cwd = accpath)
subprocess.Popen(["git","init"],cwd = accpath)
subprocess.Popen(["git","add","."],cwd = accpath)
subprocess.Popen(["git","commit","-m","'committed'"],cwd = accpath)
p = subprocess.Popen(["git","log","-p","-1"], cwd = accpath, stdout =
subprocess.PIPE,)
stdout_value = p.communicate()[0]
t1 = repr(stdout_value)
v = subprocess.Popen(["git","status"],cwd = accpath)
std_val = v.communicate()
print(std_val)
输出是这样的
# On branch master
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: England/mana2.ttx
# deleted: England/test12121212.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
你们能帮我吗? -删除了2个文件,但没有要提交的更改。 -我只是在寻找一个明确的输出,可以作为一个报告(邮件)发送。你知道吗
这是因为
git add
只添加新文件,或修改现有文件。要从树中进行阶段性删除,您需要git rm
,正如状态所示(即使文件在物理上不在那里,这也会起作用)。你知道吗如错误所示,使用
git commit -a
将绕过此操作—它将提交所有修改和删除。但是仍然需要git add
来添加新文件。所以只要改变一下:相关问题 更多 >
编程相关推荐