I could use Git
command git log --oneline tag1 tag2
to list all commits between two tags. Then use git show --pretty="" --name-only commitId
to list the changed files in one commit.
How to achieve this using GitPython
?
If you know a git command, you can use git directly in GitPython. Taking git show --pretty="" --name-only HEAD
for example:
from git import Repo
# Suppose the current path is the root of the repository
r = Repo('.')
o = r.git.show('HEAD', pretty="", name_only=True)
print(o)
HEAD
remain unchanged as non-keyword arguments.--pretty=""
are converted to keyword arguments by removing the leading --
.--name-only
are converted to keyword arguments by removing the leading --
and being assigned the value True
.-
in the keys and commands are converted to _
. name-only
should be name_only
. git for-each-ref
should be git.for_each_ref
.The command git log --oneline tag1 tag2
does not list commits between the two tags. It lists commits reachable from any of the two tags.