gitpython- tree.traverse() does not ignore items in .gitignore

18 views Asked by At

I'm trying to traverse the list of ALL items managed by git in a repo that I have checked out in a local directory.

The basic code I have is this:


git_repo = git.Repo( '/path/to/some/directory' )

for item in git_repo.commit().tree.traverse():
   print("path: %s" % item.path )

But - it is for example listing things I have in my .gitignore file (ie: Things like .o files and .bak files)

Its very complex to ignore these on my own. Is there a way I can get gitpython to ignore/skip these items.

0

There are 0 answers