title: Using PyGitHub to push file to GitHub with Python, getting a "Branch master not found" error
body: <p>I am trying to upload a .csv file to GitHub using this code:</p>
  <pre><code>### THIS PART WOKRS ###
  g = Github(&quot;My_Access_Key&quot;)
  repo = g.get_user().get_repo('tradr')
  all_files = []
  contents = repo.get_contents(&quot;&quot;)
  while contents:
      file_content = contents.pop(0)
      if file_content.type == &quot;dir&quot;:
          contents.extend(repo.get_contents(file_content.path))
      else:
          file = file_content
          all_files.append(str(file).replace('ContentFile(path=&quot;','').replace('&quot;)',''))
  with open('./Data/PriceGrabber/PriceData.csv', 'r') as file:
      content = file.read()
  # Upload to github
  git_prefix = 'tradr/'
  git_file = git_prefix + 'PriceData.csv'
  ### THIS PART WORKS ###
  
  ### GET AN ERROR HERE BELOW ###
  if git_file in all_files:
      contents = repo.get_contents(git_file)
      repo.update_file(contents.path, &quot;committing files&quot;, content, contents.sha, branch=&quot;master&quot;)
      print(git_file + ' UPDATED')
  else:
      repo.create_file(git_file, &quot;committing files&quot;, content, branch=&quot;master&quot;)
      print(git_file + ' CREATED')
  </code></pre>
  <p>This is the error I get:</p>
  <pre><code>GithubException: 404 {&quot;message&quot;: &quot;Branch master not found&quot;, &quot;documentation_url&quot;: &quot;https://docs.github.com/rest/reference/repos#create-or-update-file-contents&quot;}
  </code></pre>
  <p>I would be fine using any method that might work better. Searching seems to say that this may be an authentication issues [1].</p>
  <p>[1] <a href="https://github.com/octokit/rest.js/issues/560" rel="nofollow noreferrer">https://github.com/octokit/rest.js/issues/560</a></p>