← Articoli

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.

  1. 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
    
  2. Eseguite ssh example.com nel terminale
  3. Eseguite git init nella cartella che preferite sul server.
  4. Eseguite git config receive.denycurrentbranch updateInstead
  5. Sul sistema locale eseguite: git add remote origin ssh://example.com:/path/to/your/repo/.git
  6. 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.

SSH con password: evitare di reinserire la password su Windows:

Vedi
How to run ssh-add on windows