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. SSH access is available on all of Kinsta’s hosting plans.
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. 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.
ssh email@example.com -p PORT "cd /www/my_site/public && git pull"
Another way of doing this is to utilize WP Pusher. Many of our clients use this and it makes it super easy, as you don’t have to know how to use Git or SSH.
Austin also has an excellent tutorial on how to set up automatic Git deploy with Kinsta using SSH.
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:firstname.lastname@example.org/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
If it’s a private repo, credentials need to be added to the git pull:
ssh email@example.com -p PORT "cd /www/my_site/public && git pull https://username:firstname.lastname@example.org/USER/REPO"
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:
ssh email@example.com -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.
Fair warning. The following overwrites changes that exist on remote with what is in the Git repo.
ssh firstname.lastname@example.org -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.