I know you can get the head of a branch directly using it's name (e.g. repo.heads.main
). Can you get the head of a branch that has illegal variable characters (e.g. feature-generate-events
) directly or do I have to iterate to get it? The hyphens are illegal (in a Python sense as @phd comments) to use as a attribute name.
Try
getattr(repo.heads, 'feature-generate-events')