how to do a git diff of current commit with last commit using gitpython?

前端 未结 5 1125
故里飘歌
故里飘歌 2021-01-14 05:12

I am trying o grasp gitpython module,

hcommit = repo.head.commit
tdiff = hcommit.diff(\'HEAD~1\')

but tdiff = hcommit.diff(\'HEAD^ H

5条回答
  •  悲哀的现实
    2021-01-14 05:34

    To get the contents of the diff:

    import git
    repo = git.Repo("path/of/repo/")
    
    # define a new git object of the desired repo
    gitt = repo.git
    diff_st = gitt.diff("commitID_A", "commitID_B")
    

提交回复
热议问题