Start using Git Hub for a live website


We currently have a live website with existing code and working on the internet. We now want to start using git hub for the same, for version control. And automate updations to the server.

a) Can we start using the Github for future changes on the existing server; CPanel or do we need to do we need to Remove all files empty CPanel and data and redeploy from scratch using Github?

GitHub can deploy website through GitHub Pages and automate all the things just like what you want, but limited to scripting on the browser-side only, for example, you cannot directly run PHP, a server-side script. So if your site is running the same server-side script directly, you cannot simply run that on GitHub Pages.

You can, however, split your site, say your landing page is hosted on GitHub then those links that need to run server-side script will still be hosted on your existing server. And you can still use GitHub on your web files containing server-side script but only to track those changes, like it is the upstream so it’s the single source of truth, as they say.

Hi Thanks for your reply.

Our challange is that do we need to remove all files from live wipe CPanel clean and then redeploy using Github or can we start doing that from as is with future deployment using Github. If we remove and redeploy that is fairly risky and dangerous for errors plus the downtime.

That sounds it has little to do with Git or GitHub, and a lot with how you do the deployment from the repository. I’m not familiar with CPanel, so I don’t know what options there are, but that process is what you need to look at. If you share a bit more about how the deployment could work, maybe someone here will have an idea.

by CPanel i mean the server of the host. We are currently hosting on Hostgator who provides us a Cpanel access to upload our files (in simple terms). Query is that with files already there is it possible to start using github only for future updates or do we need to wipe clean; and then re set up the existing site using GitHub to be able to use Git Hub. It does not sound right that we can use GitHUb on an ongoing live site, wihtout disrupting and wiping it clean.

for me, as I’ve mentioned, you can create a repo and upload all the existing files, then, you will start using GitHub to track the changes and have a single source of truth, then, simply reflect the update on your hosting provider,

this way, you don’t need to delete anything on your existing server, rather, it will just start reflecting all the changes made on GitHub,

1 Like

Git tracks files and their changes, there’s no reason why you couldn’t start from those that are already there. The question is how you get the files from the repository to your hoster. That depends on the hoster (what kinds of access do they offer?) and you (which of those do you choose to use?).

The challenge is when you commit the files from Git to existing set of files, committed to the server before Git, the same does not allow the transfer giving the error that the files already exist. Thats where were forced to question our approach.

True just trying to figure that out. No sure where to reach out to break the deadlock. The hosting team does not guide coz GitHub is not their product … and so on.

As a starting point: What ways do you have to put files onto the server (or otherwise deploy)? What you wrote above sounds like a web interface, which might be hard to automate unless there’s an API.

The other question is: What do you want to control the deployment? Do you want to deploy on each push to the Git repository, or something else?

at start we have already deployed using CPanel files transfer (simple upload/ filezilla).

We want to control future changes and so push thru Git repository.

SFTP? HTTP? FTP(S)? That makes a difference in what automation tools you could use. Either way it’s probably a good idea to look at Actions: Quickstart for GitHub Actions - GitHub Docs

You could create a workflow that runs when there’s a push to the repository and then uploads to your server.