吉特尔。如何获得修改文件的真实列表?

2024-04-20 02:05:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试获取所有修改文件的列表,如下所示:

 repo_path = '.'
 repo_url = 'git@github.com:username/myfolder.git'
 repo = Gittle(repo_path, origin_uri = repo_url)
 repo.modified_files 

但我得到的文件列表相当庞大,而且包含垃圾。事实上,这与我在控制台中运行时得到的列表无关:

 $ git status

所以,我的问题是如何使用Gittle库获得修改文件的真实列表。我需要这个列表以便执行添加和提交。你知道吗


Tags: 文件pathgitgithubcomurl列表username
1条回答
网友
1楼 · 发布于 2024-04-20 02:05:44

听起来你执行的路径不对。你知道吗

import os
path = '/path/to/repo' # or use input from command line
savedPath = os.getcwd()

# do init stuff

os.chdir(path)

# do repo stuff
repo_path = '.'
repo_url = 'git@github.com:username/myfolder.git'
repo = Gittle(repo_path, origin_uri=repo_url)

print repo.modified_files

# finish repo stuff

os.chdir(savedPath)

# do other stuff

相关问题 更多 >