Skip to content

Instantly share code, notes, and snippets.

@jasenmichael
Last active December 27, 2018 20:06
Show Gist options
  • Save jasenmichael/f2ae36bee6cab564309c9b762485611f to your computer and use it in GitHub Desktop.
Save jasenmichael/f2ae36bee6cab564309c9b762485611f to your computer and use it in GitHub Desktop.
use git to deploy via sftp

use git to deploy via sftp

this method can be used to push your project to a service like GoDaddy, HostGator, or BlueHost that is running git.

  • create a remote repository on your server

    • ssh into the server

    • cd into the directory

mkdir .git
cd .git
git init --bare
cd hooks
touch post-receive
chmod +x post-receive
  • paste this into the post-receive file you just created, replace path with your project directory
#!/bin/sh
GIT_WORK_TREE=/home/user/public_html/your-dir git checkout -f

  • now we add the remote repository to our local dev project
git remote add bluehost user@your_domain.com:/home/user/public_html/your_dir/.git
git add -A
git status
git commit -m "added dev site"

//if also hosted on github etc.
git push -u origin master

//push to new repo
git push -u bluehost master

https://stackoverflow.com/questions/17876843/how-to-push-to-both-github-and-live-server-from-local-repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment