workflow: vs code → mamp → github → auto-deploy to hostinger
set your name and email (required before first commit):
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"
verify configuration:
git config --global user.name
git config --global user.email
github requires a personal access token instead of password:
using the token:
when git asks for password during push, paste your token instead of your github password
test in browser:
http://localhost:8888
navigate to project:
cd C:\Users\Matej\Desktop\codelabhaven\projects\my-new-project
initialize git:
git init
stage files:
git add .
create commit:
git commit -m "Initial commit"
set branch:
git branch -M main
link remote:
git remote add origin https://github.com/Matej398/my-new-project.git
push to github:
git push -u origin main
after making changes, run these three commands:
git add .
git commit -m "describe your changes"
git push
each project should have its own unique secret for security.
open powershell and run this command:
([System.BitConverter]::ToString((1..32 | ForEach-Object { Get-Random -Maximum 256 })) -replace '-','').ToLower()
this generates a 64-character secret that matches your existing format
option a: using filezilla (easier)
option b: using ssh terminal
ssh root@srv751763.hstgr.cloud
nano /var/www/html/codelabhaven/repositories.json
add your project to the repositories array (add a comma after the last project, then add this):
{
"name": "my-new-project",
"owner": "Matej398",
"branch": "main",
"path": "/var/www/html/codelabhaven/projects/my-new-project",
"secret": "YOUR_GENERATED_SECRET_HERE",
"post_commands": []
}
save the file:
now configure github to trigger deployments when you push code:
webhook configuration:
payload url: (copy this exactly)
https://codelabhaven.com/gh-hooks/webhook-handler.php
content type:
secret: (paste the secret you generated in step 5.1)
paste your unique secret here
which events would you like to trigger this webhook?
active:
click the green add webhook button at the bottom
test it by making a change and pushing:
git add .
git commit -m "test auto-deploy"
git push
your site should be live at:
https://codelabhaven.com/projects/my-new-project/
workflow:
1. edit code → 2. test mamp → 3. git push → 4. webhook → 5. live
quick deploy commands:
git add .
git commit -m "your changes"
git push
git status
check repository state
git diff
view file changes
git log
view commit history
git checkout -- file
discard changes
git pull
fetch latest changes
git checkout -b branch
create new branch
solution: use personal access token
solution: verify remote url
git remote -v
diagnostics:
ssh root@srv751763.hstgr.cloud
tail -f /var/www/html/codelabhaven/gh-hooks/deploy.log
solution:
# check conflicted files
git status
# edit files to resolve
# then stage and commit
git add .
git commit -m "resolved conflicts"
git push
system: vs code -> mamp -> github -> hostinger vps (srv751763.hstgr.cloud)
webhook: https://codelabhaven.com/gh-hooks/webhook-handler.php
config: /var/www/html/codelabhaven/repositories.json
status: operational ✓