Forums

Pull update from my local app to pythonanywhere webapp

I have installed a webapp on PAW, which runs perfectly.

I struggle badly with updating it, or better say with a deeper understanding of the workflow. I have a paid account. I tried to followpush deployments post.

After creating the post-receive file. I got stuck. GIT_WORK_TREE=/var/www/sites/mysite git checkout -f after running this the bash declared: fatal: You are on a branch yet to be born

not surprised as I didn't understand what I was doing

!/bin/bash Is this still in PAW bash? I could not locate the address: /var/www/sites/mysite

To anticipate the next hurdle: git remote add pythonanywhere myusername@ssh.pythonanywhere.com:/home/myusername/bare-repos/mysite.git

Does this line should be executed from my local station (I work on pycharm and commit to a git repo)?

As always, many thanks for any consideration, input or a detailed tutorial that bridges the gaps of newbies like me.

The lines that start with

1
#!/bin/bash

...inclusive are meant to be put into the post-receive file -- were you entering them into a Bash console instead?

Thanks! Yes...directly to the Bash console...

To recap: I opened the post-receive file and pasted inside:

1
2
3
#!/bin/bash
mkdir -p /var/www/sites/mysite
GIT_WORK_TREE=/var/www/sites/mysite git checkout -f

I opened a new Bash and run: chmod +x ~/bare-repos/mysite.git/hooks/post-receive

Next, in PyCharm in the terminal of my root directory: I pasted git remote add pythonanywhere myusername@ssh.pythonanywhere.com:/home/myusername/bare-repos/mysite.git (modifying it to my needs).

So I should run now: git push -u pythonanywhere master

Yet, as my webapp in up and running with sqlite DB, I wanted to verify that it would stay there... is it a wishful thinking? If yes to execute it properly?

If you want to update your site, then run git push -u pythonanywhere master from your local machine (assuming you have local changes to push).

I don't understand our last question. Is what wishful thinking?

I referred to my DB on PAW. Does the update process (push command) can delete my DB. As my db is an sqlite3 file, I wish to ensure the push update only update new entries. In case it isn't safe can you kindly advise on the procedure to follow before push -u?

If you have your sqlite database committed into git, then the push will replace the sqlite file that you have on PythonAnywhere and overwrite it with whatever you have locally. Git does not distinguish between new or old entries in your database - git works on files.

If you do not want your sqlite database to be overridden on every push, do not include it in your git repository.