Skip to content

Instantly share code, notes, and snippets.

@ivsanro1
Last active August 5, 2022 09:24
Show Gist options
  • Select an option

  • Save ivsanro1/d58d095ce582710dc8c68f0550d9bdd1 to your computer and use it in GitHub Desktop.

Select an option

Save ivsanro1/d58d095ce582710dc8c68f0550d9bdd1 to your computer and use it in GitHub Desktop.
Simple but useful utility to get the root of the current project (has to be a git project)
import git
import os
from pathlib import Path
def get_root() -> Path:
return Path(git.Repo(os.getcwd(), search_parent_directories=True).working_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment