git log –follow, the gitpython way

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

git log --follow -- <filename>

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

  • Deleting Files using Git/GitHub
  • Makefile error: Unexpected end of line seen
  • How to merge the gerrit branch to another gerrit branch
  • Get only sub-directories with Git?
  • How can I remove the history of one file in git, leaving only the most recent version?
  • perforce diff to git
  • import git 
    g = git.Git('repo_dir') 
    hexshas = g.log('--pretty=%H','--follow','--',filename).split('\n') 

    then I build commit objects:

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

    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.

  • How to recover from git-svn putting a different cased dulplicate file in the repository?
  • Unable to install the latest version of Gitlab
  • Advantages of categorizing objects into folders named as the first 2 characters of SHA-1 string?
  • How to clone/fetch a git repository with libgit2?
  • Releasing using workflow plugin in Jenkins
  • git reset <file> versus git reset — <file>
  • One Solution collect form web for “git log –follow, the gitpython way”

    For example,

    With range time:

    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 Baby is a git and github fan, let's start git clone.