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.
- 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 - Exécutez
ssh example.comdans le terminal - Exécutez
git initdans le dossier de votre choix sur le serveur. - Exécutez
git config receive.denycurrentbranch updateInstead - Sur le système local, exécutez :
git add remote origin ssh://example.com:/path/to/your/repo/.git - 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.