Is it possible to deploy code from a Cloudways app to an empty git repository? I would like to know if it's possible as I'm currently using FTP (Filezilla) for that. I'm able to clone a live site to a staging site, but cannot deploy it to Github in order to work on the files on my local machine.
3 Answers
First, create an empty repository on Github.com. Then log into your Cloudways dashboard, open your application and set up "Deployment via Git". When all that's done, open a command line application (eg. Terminal on Mac) and log in using your SSH credentials. Next up you'll be executing a handful of Git commands:
First, you need to turn your server code into a local repository, by running the git init
command in the public_html
directory. This creates a .git
subdirectory, which contains all of the necessary metadata for the new repository. Next you create a snapshot using git add .
, and then you use git commit -m "My Cloudways Repo"
to capture the state of the snapshot. My Cloudways Repo
is a message for this initial commit and can be anything. After that, set a new remote using git remote add origin git@git.yourdomain.com:username/name_of_repo.git
, this is the same address you've used to setup "Deployment via Git". Finally, you use git push origin master
to push the code to the remote Github server.
Summarized:
Using command line, navigate to your application folder: /home/master/applications/yourdomain.com/public_html
then execute the following commands (one by one so you can read the responses):
git init
git add .
git commit -m "My Second Repo Cloudways"
git remote add origin git@git.yourdomain.com:username/name_of_repo.git
git push origin master
You can learn more about git init
, git add
and git commit
here:
https://www.atlassian.com/git/tutorials/setting-up-a-repository https://www.cloudways.com/blog/wordpress-github/#create-repository-on-github

- 185
- 2
- 13

- 14,958
- 21
- 75
- 105
-
Thanks for the guide. However I got this error in the last stage: git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. – Webninja Feb 03 '23 at 09:58
You should first make sure you can deploy your Cloudways application (that you have copied through filezilla locally) with Git, and pushed to a GitHub repo:
See "Deploy Code to Your Application Using Git".
Once your SSH access is setup, you can click "start deployment" to initiate the process. It will fetch the GitHub repo, and deploy it.
That means, to the question "Is it possible to deploy the code from a cloudways app to an empty git repository?": no, the publication process is the other way around.
That would involve:
- Generating and downloading SSH keys
- Uploading the SSH public key to your Git Repository
- Copying the Repository SSH address
- Deploying code from your Repository
The last step being:
- Back on Cloudways console, paste the SSH address you got in Step 4 into the Git Remote Address field and click on the Authenticate. This will ensure that there are no blockers in the communication between Cloudways and Git service (which is Github in our example) .
- Then choose the branch of your repository (master will be selected as default) you want to deploy from.
- Next, type the deployment path (i.e. the folder in your server where the code will be deployed). Make sure to end it with a
/
.
If you leave this field empty, the code will be deployed topublic_html/
.- Finally, click on the Start Deployment button to deploy your code to the selected path.

- 1,262,500
- 529
- 4,410
- 5,250
-
2This deploys FROM github TO cloudways, which I have no problem doing. What I'm asking is if it's possible to get the files FROM cloudways TO github, which I can then pull to my local repository. – user3752231 Nov 29 '18 at 06:51
-
@user3752231 you can clone an app to a new server (https://support.cloudways.com/how-do-i-clone-an-application-on-my-server/): can you check if you can acess that new cloned repo on a new server? If yes, you should be able to clone it locally (before pushing it to GitHub) from that server ssh url. – VonC Nov 29 '18 at 07:12
-
2I tried something like that, in that I cloned the live app to a staging app, not sure if I have the permissions to a new server, but If i did I still don't see any option for pushing it using Git. I'm just checking if possible with Git, their documentation doesn't mention it. If not then I can manage with ftp, then overwriting the staging files with the newly edited ones. – user3752231 Nov 29 '18 at 08:20
-
@user3752231 not pushing, but cloning first to your local PC, then pushing from your local PC to GitHub. – VonC Nov 29 '18 at 08:21
-
I am able to deploy my code from a Git repo to cloudways with no problems by the way – user3752231 Nov 29 '18 at 08:22
-
is there an option to clone from cloudways to local using Git? Because I've only seen the option to integrate a clouways app with a GitHub repositiory and not the local, unless you mean I can use a Git address from my local for the Git remote address option? – user3752231 Nov 29 '18 at 08:25
-
@user3752231 if you can connect through ssh to the cloudapp server and go to the repo folder, you could use that as an SSH URL to clone (from your PC) that repo. – VonC Nov 29 '18 at 08:26
-
@user3752231 did you find the correct SSH URL to use in order to clone from the cloudways server to your PC, and then push to GitHub? – VonC Nov 29 '18 at 15:22
-
The answer says "you should first", but then fails to answer the real question. Please update this answer with proper instructions on how to deploy from Cloudways to Github (and we all know the other one around is easy to do). – bart Mar 18 '19 at 00:47
-
As my Git repository does not have the .env file, when I pull to Cloudways, this production file is being deleted. Is there a way to keep this file that is already in production unchanged, given that there is no such file on GitHub? Currently, every time I deploy, I need to go to the production environment and reconfigure the .env file with database information, etc. – Paulo Costa Jul 16 '23 at 02:14
-
@PauloCosta That is why content filter drivers exist: see the second part of [my answer to "Ignore other `.gitignore` files than the one in root"](https://stackoverflow.com/a/71391591/6309) for illustration. – VonC Jul 16 '23 at 07:40
First, you need to create a new repository on GitHub. Then, launch Cloudways SSH terminal (Server Management Panel > Master Credentials > Launch SSH Terminal) and paste your credentials. Now run these commands:
cd applications/xxxxxx/public_html. xxxxxx is a folder name.
git init
git add .
git checkout -b master
git commit -m "first commit"
If you see this message “Please tell me who you are”, then run these two commands
git config --global user.email "you@example.com" //
git config --global user.name "Your Name"
git remote add origin https://github.com/farhanayub/GitHub.git
git push origin master
Then insert GitHub username and password.
If you see any error then run the following and repeat the steps again.
rm -rf .git/
For your reference: https://www.cloudways.com/blog/wordpress-github/

- 164
- 4