Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何使用脚本获取文件_Python 3.x_Git_Shell_Scripting - Fatal编程技术网

Python 3.x 如何使用脚本获取文件

Python 3.x 如何使用脚本获取文件,python-3.x,git,shell,scripting,Python 3.x,Git,Shell,Scripting,如何使用git获取文件名,我希望自动添加文件名,例如: git ls-files -m # show me just files affected with changes example/example.py 我想循环我的所有项目,得到一个名称文件,并将该名称放入一个字符串中,如下面所示: example.sh # first check status git status # show files affected git ls-files -m echo "your chang

如何使用git获取文件名,我希望自动添加文件名,例如:

git ls-files -m # show me just files affected with changes
example/example.py
我想循环我的所有项目,得到一个名称文件,并将该名称放入一个字符串中,如下面所示:

example.sh
# first check status
git status
# show files affected
git ls-files -m
echo "your changes in files $(git ls-files -m)" 
# add files
git add .
# add var name files
NAME_FILES = git ls-files -m # NOT WORKING
# add commit
git commit -m "files added $(NAME_FILES)" # but this line not working
当我显示日志时,只显示“已添加文件”,而不显示已添加文件的名称

请帮帮我

如果您愿意,谢谢

但是,如果在
git add
步骤之后执行git ls files,则需要():


您应该将您的文件添加到暂存区中那些被修改的文件,然后进行提交以避免混淆,但我需要的是将一个名称文件保存在一个var中,并将该名称放入git提交中,如下所示:“name_files=git ls files-m,并且当像git提交一样提交时-m“您的文件受$(name_files)“@angelomarromajaspacheco OK。我已相应地编辑了答案。
git add -u
NAME_FILES=$(git status --porcelain|tr '\n' ' ')
git commit -m "files added ${NAME_FILES}"