Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Git push to HostGator
Clone this wiki locally
FTP blows and you want to simply
git push hostgator master out to your desired directory. It's pretty easy.
- You've gotten Hostgator to authorize you to use SSH
- The server has git
- You know that Hostgator uses port 2222 for SSH
Step 1: Put your public key on the server
Go ahead and SSH into the box:
ssh USER_NAME@your-domain.com -p 2222 ... Enter your password: *****
Copy your public key from your machine. It's typically found in
~/.ssh/id_rsa.pub. Open that file in Sublime (or something) and copy it. Then, on the Hostgator server, paste it in the following file:
~/.ssh/authorized_keys. It's possible that the authorize_keys file may not exist. If that's the case just
touch authorized_keys in that directory to create it.
Step 2: Initialize a repo and configure it
cd into your directory. An example might be
/www/your-domain.com. Initialize the repo with:
After that, configure the repo to accept pushes into this working directory. Run this:
git config --add receive.denyCurrentBranch ignore
Of course, once commits are pushed, they must be checked out. Save the following in a file at:
GIT_WORK_TREE=../ git checkout -f
Then make it executable with:
chmod +x PATH_TO_REPO/.git/hooks/post-receive
Step 3: Setup your SSH config locally
Let's make it simple to connect to hostgator via SSH. Open
~/.ssh/config on your local machine and add an entry to it.
Host hostgator User USER_NAME HostName YOUR_DOMAIN Port 2222 PreferredAuthentications publickey
Now, you can simply
ssh hostgator and get a connection.
Step 4: Setup Hostgator as a git remote
On your local machine, navigate to your repo and run the following command:
git remote add hostgator ssh://firstname.lastname@example.org:2222/full/path/public_html/your-domain.com
I had to add the full path to get everything to work properly. You can find the full path in your control panel.
Step 5: git push
Now you can simply:
git push hostgator master