2016-09-27 101 views
0

我正在编写一个Python脚本,在那里我需要知道特定文件的所有提交。在我的代码中,我使用GitPython来完成其他任务,但是对于这个问题我找不到任何东西。GitPython列出特定文件的所有提交

在CMD行我使用:

git log --pretty='%H' file-path 

回答

0

我们正在寻找在Git是:

git log --follow filename 

不知道GitPython有寿。

0

您可以查询提交上,你克隆了“回购”:

commits = repo.iter_commits('--all', max_count=100, since='10.days.ago', paths=path) 

...因此“ - 所有”将返回所有的分支和标签提交,路径是你的文件名。

,并使用你去喜欢提交:

for commit in commits: 
    print("Committed by %s on %s with sha %s" % (commit.committer.name, time.strftime("%a, %d %b %Y %H:%M", time.localtime(commit.committed_date)), commit.hexsha)) 
相关问题