How to Use Git at Kinsta

Updated on April 16, 2018

git

We have the Git client available at Kinsta so you can SSH in and pull your own Git repo down from Github, Gitlab, Bitbucket, or any other third-party. However, we don’t yet have the feature released yet where you can just git push kinsta my_site and it automatically gets deployed. This part is coming soon. But you can still easily use Git at Kinsta, just follow the instructions below.

How to Use Git

You can create a deployment script in a few minutes that will SSH into your Google Cloud Linux container and pull down the latest version of your repo. Instead of doing git push kinsta my_site and being done, you’ll need to add the following:

Push

git push kinsta my_site

Pull

ssh my_site@1.2.3.4 -p PORT "cd /www/my_site/public && git pull"

Note: We only offer SSH access on our Business 1 and higher plans. So for those of you on our Starter or Pro plans, another way of doing this is to utilize WP Pusher. Many of our clients use this and it makes it super easy, no Git or SSH required.

Some other alternatives include Beanstalk and DeployBot. Otherwise, you can follow the more detailed Git instructions below.

Clone Rep

To clone a repo:

git clone https://github.com/USER/REPO.git

When using Git for private repositories, you use your GitHub username and password which are passed to the server.

git clone https://username:password@github.com/USER/REPO.git

If two-factor authentication is enabled, an OAuth token must be used in place of your standard credentials. Follow these instructions on how to create an OAuth token.

To clone a repo that has 2FA enabled:

git clone https://TOKEN@github.com/USER/REPO.git

Deploy Repo

To deploy a repo:

Push

git push kinsta my_site

Pull

ssh my_site@1.2.3.4 -p PORT "cd /www/my_site/public && git pull"

Deploy Private Repo

If it’s a private repo, credentials need to be added to the git pull:

Push

git push kinsta my_site

Pull

ssh my_site@1.2.3.4 -p PORT "cd /www/my_site/public && git pull https://username:password@github.com/USER/REPO"

Deploy Private Repo With 2FA

If two-factor authentication is enabled, an OAuth token must be used in place of your standard credentials. Follow these instructions on how to create an OAuth token. To deploy a repo that has 2FA enabled:

Push

git push kinsta my_site

Pull

ssh my_site@1.2.3.4 -p PORT "cd /www/my_site/public && git pull https://TOKEN@github.com/USER/REPO"

If the git pull above doesn’t contain credentials and the HTTPS path, it will attempt to look locally (rather than at the hosted repo) and throw the message: “Everything up-to-date.”

Dealing With Conflicts Found

If you change something on remote the deployment commands above will abort due to conflicts found. What should you do then? It depends on which one you want to treat as “King.” In this example below, we will treat the Git repo as “King” and forget the conflicts.

Force Pull

Fair warning. The following overwrites changes that exist on remote with what is in the Git repo.

ssh my_site@1.2.3.4 -p PORT "cd /www/MY_SITE/public && git fetch https://TOKEN@github.com/USER/REPO.git && git reset –hard kinsta/mysite"

If you have questions regarding how to use Git at Kinsta our support department will be happy to help once you’re up and running.

Was this article helpful?
No, or there was something off

Hand-picked related articles

Use WordPress?

Join 20,000+ others who get our FREE weekly newsletter with WordPress tips on how to drive more traffic and revenue to your business!

You have Successfully Subscribed!

Send this to a friend