本文介绍了git log --follow,gitpython方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问单个文件的提交历史记录,如:

I am trying to access the commit history of a single file as in:

git log --follow -- <filename>

我必须使用 gitpython ,所以我现在要做的是:

I have to use gitpython, so what I am doing now is:

import git
g = git.Git('repo_dir')
hexshas = g.log('--pretty=%H','--follow','--',filename).split('\n')

然后我构建提交对象:

repo = git.Repo('repo_dir')
commits = [repo.rev_parse(c) for c in r]

有没有一种方法可以使用gitpython-ic呢?我尝试了 commit.iter_parents() commit.iter_items(),但是它们都依赖于 git-rev-list ,所以他们不这样做没有-follow 选项.

Is there a way to do it in a more gitpython-ic way?I tried both commit.iter_parents() and commit.iter_items(), but they both rely on git-rev-list, so they don't have a --follow option.

推荐答案

例如,

有范围时间:

g = git.Git("C:/path/to/your/repo")
loginfo = g.log('--since=2013-09-01','--author=KIM BASINGER','--pretty=tformat:','--numstat')
print loginfo

输出:

3       2       path/in/your/solutions/some_file.cs

您可以看到添加的行,删除的行以及具有这些更改的文件.

You can see the added lines, removed lines and the file with these changes.

这篇关于git log --follow,gitpython方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 16:58