Miyazaki, 2. November 2022
How to deploy with git
As a big fan of the IndieWeb, I'd like to inform you that you don't need GitHub, render, netlify or other apps to host and deploy your own website. A Linux VPS is enough.
- Set up a VPS with SSH access. Set up SSH key login in ~/.ssh (Works on windows too!)
Host example.com User yourUser IdentityFile ~/.ssh/keyfile IdentitiesOnly yes
- Run
ssh example.com
in the terminal - Run
git init
in the folder of your choice on the server. - Run
git config receive.denycurrentbranch updateInstead
- On the local system run:
git add remote origin ssh://example.com:/path/to/your/repo/.git
- Now you can push and pull to your server and the folder will update!
This is how I published this blogpost!
Common Error that is solved:
If we don't set git config
receive.denycurrentbranch updateInstead
we will get this error:
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.