I've been trying to link a local python flask repo to my remote (production) vm in the google cloud.
On Google VM :
sudo mkdir /home/git && cd /home/git
sudo mkdir flask_project.git && cd flask_project.git
sudo git init --bare
sudo vim hooks/post-receive
{Added}
#!/bin/sh
GIT_WORK_TREE=/home/www/flask_project git checkout -f
sudo chmod +x hooks/post-receive
On Local dev
git init
git remote add production web@<externalip>:/home/git/flask_project.git
I've generated SSH keys and added public key to GCP Metadata but when I push commits from local to remote :
git push production master
Git stalls and the commit doesn't reach remote.
Any ideas how I can link the repo's?
Your /home/git/flask_project.git
bare repo is owned by root
after the steps you executed.
But you're attempting to operate it as web
(according to your remote production config), which doesn't have write permissions on the bare repo. I suspect that depending on the OS this may cause the hanging - on my older opensuse it just fails with:
remote: error: insufficient permission for adding an object to repository database objects
Try sudo chown -R web /home/git/flask_project.git
Alternatively, if you plan to push to that repo as multiple users (git
comes to mind), you could use the git init --bare --shared
to create the bare repo instead. Not a great practice, tho.
Side note: you also need to clone the repo in /home/www/flask_project
(as web
as well) before the hook can operate properly, otherwise you'll probably get something like:
remote: fatal: This operation must be run in a work tree