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

Ciasto piekarz

I am trying o grasp gitpython module,

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

but tdiff = hcommit.diff('HEAD^ HEAD') doesn't work !! neither does ('HEAD~ HEAD').,

I am trying to get the diff output !

Ciasto piekarz

I figured out how to get the git diff using gitPython.

import git
repo = git.Repo("path/of/repo/")

# the below gives us all commits
repo.commits()

# take the first and last commit

a_commit = repo.commits()[0]
b_commit = repo.commits()[1]

# now get the diff
repo.diff(a_commit,b_commit)

Voila !!!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to confirm that current git diff is one with current and last and not with current commit and any other

From Dev

how to confirm that current git diff is one with current and last and not with current commit and any other

From Dev

How to diff a commit with its parent in GitPython

From Dev

Not able to commit file to git using gitpython library

From Java

See diff between current state and last commit

From Dev

How to copy the last commit as a new commit in Git?

From Dev

Git last commit hash and current version

From Java

How to undo the last commit in git

From Dev

How do I refer to the last commit in a branch with git?

From Dev

GitPython: how to commit updated submodule

From Dev

GitPython: how to commit updated submodule

From Dev

Get the diff details of first commit in GitPython

From Dev

How to remove ignored files from current commit using git commit --amend

From Dev

Using git hooks to create a diff report for every file that has changed for the current commit

From Java

How to retrieve the hash for the current commit in Git?

From Java

How to view file diff in git before commit

From Dev

How to remove not-last commit in Git?

From Java

How to add a file to the last commit in git?

From Dev

How to add untracked file in last git commit?

From Dev

How to get second last commit hash in git

From Dev

How to remove not-last commit in Git?

From Dev

git how to recover the last commit files

From Dev

git diff last commit plus all uncommitted changes?

From Java

How do you "rollback" last commit on Mercurial?

From Dev

git: Show message of last commit in commit template

From Dev

git: Show message of last commit in commit template

From Dev

GitPython git diff for the last so many days

From Dev

How do I git checkout one commit prior to a specific commit

From Dev

List file that have changed since last commit with GitPython

Related Related

  1. 1

    how to confirm that current git diff is one with current and last and not with current commit and any other

  2. 2

    how to confirm that current git diff is one with current and last and not with current commit and any other

  3. 3

    How to diff a commit with its parent in GitPython

  4. 4

    Not able to commit file to git using gitpython library

  5. 5

    See diff between current state and last commit

  6. 6

    How to copy the last commit as a new commit in Git?

  7. 7

    Git last commit hash and current version

  8. 8

    How to undo the last commit in git

  9. 9

    How do I refer to the last commit in a branch with git?

  10. 10

    GitPython: how to commit updated submodule

  11. 11

    GitPython: how to commit updated submodule

  12. 12

    Get the diff details of first commit in GitPython

  13. 13

    How to remove ignored files from current commit using git commit --amend

  14. 14

    Using git hooks to create a diff report for every file that has changed for the current commit

  15. 15

    How to retrieve the hash for the current commit in Git?

  16. 16

    How to view file diff in git before commit

  17. 17

    How to remove not-last commit in Git?

  18. 18

    How to add a file to the last commit in git?

  19. 19

    How to add untracked file in last git commit?

  20. 20

    How to get second last commit hash in git

  21. 21

    How to remove not-last commit in Git?

  22. 22

    git how to recover the last commit files

  23. 23

    git diff last commit plus all uncommitted changes?

  24. 24

    How do you "rollback" last commit on Mercurial?

  25. 25

    git: Show message of last commit in commit template

  26. 26

    git: Show message of last commit in commit template

  27. 27

    GitPython git diff for the last so many days

  28. 28

    How do I git checkout one commit prior to a specific commit

  29. 29

    List file that have changed since last commit with GitPython

HotTag

Archive