Having this code
from dulwich.objects import Blob, Tree, Commit, parse_timezone
from dulwich.repo import Repo
from time import time
repo = Repo.init(\"myrep
It is now possible since release 0.8.4, with the method dulwich.index.build_index_from_tree().
It writes a tree to both the index file and the filesystem (working copy), which is a very basic form of checkout.
See the note
existing index is wiped and contents are not merged in a working dir. Suiteable only for fresh clones
I could get it work with the following code
from dulwich import index, repo
#get repository object of current directory
repo = repo.Repo('.')
indexfile = repo.index_path()
#we want to checkout HEAD
tree = repo["HEAD"].tree
index.build_index_from_tree(repo.path, indexfile, repo.object_store, tree)