title: Find the root of the git repository where the file lives
body: <p>When working in Python (e.g. running a script), how can I find the path of the root of the git repository where the script lives?</p>
  
  <p>So far I know I can get the current path with:</p>
  
  <pre><code>path_to_containing_folder = os.path.dirname(os.path.realpath(__file__))
  </code></pre>
  
  <p>How can I then find out where the git repository lives?</p>