Forums

Pushing Existing App Folder in PythonAnywhereto Github

Hi

How can we push an existing web app folder in python to github and make a commit so that we can pull it from github in future to if the web app collapse in PythonAnywhere due to future edits.

Here are the steps:

  • If your folder is not already a Git repository, use "git init" to make it one, add a .gitignore file (so that you don't wind up committing pyc files and __pycache__ directories, and then commit your code.
  • On github, create a repository.
  • The last step of creating the repository there will have commands to push from an existing repository (like the one you have on PythonAnywhere), with commands like "git remote add origin". Follow those instructions.

Thanks Giles

As I am new to this I need more detailed steps.

I run the command git init and following is the result:-

(django2) 03:13 ~/mysite $ git init Reinitialized existing Git repository in /home/bnyrj/mysite/.git/

I couldnt do the following from the steps you said which I would like to request you to explain in details-

  1. add a .gitignore file (so that you don't wind up committing pyc files and pycache directories, and then commit your code.
  2. The last step of creating the repository there will have commands to push from an existing repository (like the one you have on PythonAnywhere), with commands like "git remote add origin". Follow those instructions.

Read this.

And also follow github instructions for how to create/import a repository to github.

Hi

When I checked the link you gave its says the below:-

Importing a new project Assume you have a tarball project.tar.gz with your initial work. You can place it under Git revision control as follows.

$ tar xzf project.tar.gz $ cd project $ git init

I dont have the above said tarball project.tar.gz. So can you tell me how to proceed with pushing PythonAnywhere project to GitHub (I hope the git tutorial you provided is applicable for GitHub as well)

Regarding this:

add a .gitignore file (so that you don't wind up committing pyc files and pycache directories, and then commit your code.

A .gitignore file is a text file that lives in the directory where you ran "git init". It contains multiple lines, each of which tells git about a type of file to ignore. So if you create one with the following lines:

*.pyc
__pycache__

...then you'll have one that will ignore Python's temporary files.

The last step of creating the repository there will have commands to push from an existing repository (like the one you have on PythonAnywhere), with commands like "git remote add origin". Follow those instructions.

This bit should become clear once you've created the repository on GitHub.