Miyazaki, 2 novembre 2022
Come fare il deploy con git
Da grande sostenitore dell’IndieWeb, vorrei farvi sapere che non servono GitHub, Render, Netlify o altre app per ospitare e pubblicare il proprio sito web. Basta un VPS Linux.
- Configurate un VPS con accesso SSH. Impostate il login con chiave SSH in ~/.ssh (funziona anche su Windows!)
Host example.com User yourUser IdentityFile ~/.ssh/keyfile IdentitiesOnly yes - Eseguite
ssh example.comnel terminale - Eseguite
git initnella cartella che preferite sul server. - Eseguite
git config receive.denycurrentbranch updateInstead - Sul sistema locale eseguite:
git add remote origin ssh://example.com:/path/to/your/repo/.git - Ora potete fare push e pull sul vostro server e la cartella si aggiornerà!
È così che ho pubblicato questo articolo!
Errore frequente risolto in questo modo:
Se non impostiamo la configurazione git
receive.denycurrentbranch updateInstead otteniamo questo errore:
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.