Search code examples
gitgithubpythonanywhere

How to clone an existing web application from pythonanywhere to github/local


I would like to create a clone/copy of an existing web application on pythonanywhere. I have access to the pythonanywhere account. The application is active and is not mine - a friend is allowing me to make a copy so that I can learn how web applications work. Thus, it is important that I can make a copy without messing up or updating anything in the current web application.

All of the tutorials I am finding are about deploying an application via git to github to pythonanywhere (which I have done before) but never the other way around.

I created an empty github repository and thought about going to the python bash console and adding it as a remote server, then pushing the code to github. But, I don't know if this makes a new connection that will mess up the application. I want to just download the application once and be done.

I would really appreciate step-by-step instructions on how to download a copy of the web application to my local server and/or github. If you provide code, please assume I know nothing and tell me where I should run it (command prompt, pythonanywhere bash console, etc).


Solution

  • I just did this the following way. In a bash console on pythonanywhere, navigate to the app with $cd yourapp. Then create a git repository there with git init. Once its done add the folders in the app to the repo with git add . Then you need to commit to update the empty repository: git commit -m "your comment".

    Once the repo is created on pythonanywhere, move to the local folder in your local machine's terminal where you want to copy the app. Then clone the repo on pythonanywhere with entering the following command to your local terminal: git clone [email protected]:/home/yourusername/yourapp

    Since its not a bare repository, you won't be able to push any code changes to the pythonanywhere app, by default. This can be changed though, but I understand that is not what you want. If you want to make sure that no changes are applied back, just delete the .git folder from pythonanywhere which was created by the git init

    My concern though is, that if your friend's app is database backed, you might be able to send data to the live database from your local instance of the app. So, definitely double check on that with him/her.