Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is it possible to use Repo.iter_commits or other API to get renames of files? #1477

Answered by Byron
Guo-Zhang asked this question in Q&A
Discussion options

I want to track a file with its rename ones. For example, a file is called "test_lecture", and then rename to "python_data_analytics". I want to track all the commits for the files if possible.

I use Repo.iter_commits currently, which requires on git rev-list command, a complicated command(https://stackoverflow.com/questions/64397278/understanding-git-rev-list).

I have noticed that git log with --follow and --find-renames(https://www.zhihu.com/question/531483642/answer/2472733253) may work. Or are there any API based on it can be used?

You must be logged in to vote

I don't think that out of the box this is easy in GitPython, but it should be possible to use git directly and parse its output instead.
GitPython can make calling into git more pythonic, too, but it won't change the fact that you have to deal with a steam of bytes to parse.

Replies: 1 comment

Comment options

I don't think that out of the box this is easy in GitPython, but it should be possible to use git directly and parse its output instead.
GitPython can make calling into git more pythonic, too, but it won't change the fact that you have to deal with a steam of bytes to parse.

You must be logged in to vote
0 replies
Answer selected by Byron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1476 on August 10, 2022 01:41.

AltStyle によって変換されたページ (->オリジナル) /