1

I wanna use Replit for pushing from a Python script into a Github repo of mine. On Replit I created an Python script and connected it with an Github repo.

If I do this locally than I just use my local path to the repo which I wanna push. How do I assign a path if I wanna do it on Replit?

Here is the code which I use to make a Github push from a Python script locally:

from git import Repo

PATH_OF_GIT_REPO = r'/here/is/the/path/to/the/file/which/I/wanna/push'  
COMMIT_MESSAGE = 'comment from python script'

def git_push():

  repo = Repo(PATH_OF_GIT_REPO)
  repo.git.add(update=True)
  repo.index.commit(COMMIT_MESSAGE)
  origin = repo.remote(name='origin')
  origin.push()
            

git_push()
Max Hager
  • 536
  • 4
  • 13
  • Why do you not assign a path on Replit in the same way as you assign a path locally? – mkrieger1 Apr 24 '22 at 21:22
  • You are right. But if I add the path I get an `'fatal: The current branch main has no upstream branch.'` because it seems like the push command is not authorized via script from Replit. But it is possible to push via the commit & push button on Replit this confuses me. @mkrieger1 – Max Hager Apr 24 '22 at 23:26
  • Which branch in the remote repository does the "commit & push" button push to? – mkrieger1 Apr 25 '22 at 07:40

0 Answers0