← Articles

Miyazaki, 2 novembre 2022

Comment déployer avec git

Grand adepte de l’IndieWeb, je tiens à vous dire que vous n’avez pas besoin de GitHub, render, netlify ou d’autres services pour héberger et déployer votre propre site web. Un VPS Linux suffit.

  1. Mettez en place un VPS avec accès SSH. Configurez la connexion par clé SSH dans ~/.ssh (fonctionne aussi sous Windows !)
     Host example.com
       User yourUser
       IdentityFile ~/.ssh/keyfile
       IdentitiesOnly yes
    
  2. Exécutez ssh example.com dans le terminal
  3. Exécutez git init dans le dossier de votre choix sur le serveur.
  4. Exécutez git config receive.denycurrentbranch updateInstead
  5. Sur le système local, exécutez : git add remote origin ssh://example.com:/path/to/your/repo/.git
  6. Vous pouvez maintenant faire push et pull vers votre serveur, et le dossier se met à jour !

C’est ainsi que j’ai publié cet article !

Erreur courante ainsi résolue

Si l’on ne configure pas
receive.denycurrentbranch updateInstead, on obtient cette erreur :

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 avec mot de passe : éviter de le ressaisir sous Windows

Voir
How to run ssh-add on windows