Many developers using GoDaddy's shared hosting face deployment friction when relying on manual FTP transfers. The solution lies in leveraging Git's powerful version control capabilities through SSH access - a feature now commonly available even on shared hosting plans.
Before proceeding, ensure you have:
1. SSH access enabled on your GoDaddy account
2. Git installed on both local machine and server
3. Basic terminal/SSH familiarity
1. Server-Side Setup
Connect via SSH to your GoDaddy hosting:
ssh username@yourdomain.com
cd ~/your_project_directory
git init --bare project.git
2. Create Post-Receive Hook
This ensures automatic deployment after push:
cd ~/project.git/hooks
touch post-receive
chmod +x post-receive
nano post-receive
Add this script:
#!/bin/sh
GIT_WORK_TREE=/home/username/public_html git checkout -f
3. Local Repository Configuration
Add the remote repository:
git remote add godaddy ssh://username@yourdomain.com/home/username/project.git
4. Deployment Workflow
Now deploy with a simple push:
git push godaddy main
Permission Denied Errors
Ensure correct permissions on your public_html directory:
chmod -R 755 /home/username/public_html
chown -R username:username /home/username/public_html
SSH Connection Problems
Verify your SSH access works before attempting Git operations. Try establishing a basic SSH session first.
For more complex workflows, consider:
- Setting up multiple branches for staging/production
- Adding pre-receive hooks for deployment validation
- Implementing CI/CD pipelines with webhooks
Shared hosting environments may have limitations:
- Large repositories might timeout during push
- Concurrent access during deployment may cause temporary issues
- Consider shallow clones if working with large codebases
Before proceeding, ensure your GoDaddy shared hosting meets these requirements:
- SSH access enabled (request via GoDaddy dashboard if unavailable)
- Basic terminal familiarity
- Local Git repository initialized
- Shell access confirmed via
ssh yourusername@yourdomain.com
Connect to your GoDaddy server via SSH and execute:
mkdir -p ~/git/yourproject.git
cd ~/git/yourproject.git
git init --bare
This creates a bare repository that will receive your pushes. The conventional .git
suffix helps identify repository directories.
On your development machine, add the remote:
git remote add godaddy ssh://username@yourdomain.com/home/username/git/yourproject.git
Verify the remote with:
git remote -v
This automates deployment when pushing. Create ~/git/yourproject.git/hooks/post-receive
with:
#!/bin/sh
GIT_WORK_TREE=/home/username/public_html git checkout -f
Make it executable:
chmod +x hooks/post-receive
Adjust /home/username/public_html
to match your actual web root path.
For more complex scenarios, consider these hook variations:
PHP-specific deployment:
#!/bin/sh
DEPLOY_PATH=/home/username/public_html
GIT_WORK_TREE=$DEPLOY_PATH git checkout -f
cd $DEPLOY_PATH
composer install --no-dev
Node.js deployment:
#!/bin/sh
DEPLOY_PATH=/home/username/public_html
GIT_WORK_TREE=$DEPLOY_PATH git checkout -f
cd $DEPLOY_PATH
npm install --production
pm2 restart your_app
- Permission denied: Ensure your web root is writable (
chmod -R 755 public_html
) - SSH connection refused: Verify GoDaddy hasn't changed your SSH port
- Hook not executing: Check line endings (use
dos2unix
if edited on Windows)
For production environments:
- Set
GIT_WORK_TREE
outside web root when possible - Implement
.htaccess
restrictions for.git
directories - Consider using deploy keys instead of account credentials
Large repositories may benefit from:
git config --global pack.windowMemory "100m"
git config --global pack.packSizeLimit "100m"
git config --global pack.threads "1"
These settings prevent memory issues on shared hosting environments.