If you like DNray Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

Implementing version control for regular hosting sites

Started by dinesh, Oct 24, 2023, 12:05 AM

Previous topic - Next topic

dineshTopic starter

What is the way to utilize version control for a website hosted on a regular hosting service?
I am interested in transitioning the development and support of websites to Git, but there is an obstacle. The majority of client websites are hosted on regular hosting platforms that only provide FTP access, which is not very convenient for efficient work.

I have been eager to start using Git for a while now, but I am unsure of how to integrate it with such hosting platforms. The issue arises when multiple people are working on these websites and it becomes necessary to consider the potential changes already made on the hosting server.
Thus, merging everything and creating a repository on GitHub or Bitbucket is not a major concern, but I am still unclear on how to upload everything to the hosting server.
  •  


Optoroim

In your case, using Git for version control is an excellent idea, especially when multiple people are working on your websites. However, traditional web hostings that only support FTP might pose a challenge due to the lack of direct Git integration.

Below is a process you could adopt to mitigate this:

Create a Repository: Start by creating a Git repository for your website. You can do this on platforms like GitHub, Bitbucket, GitLab etc. This repository will hold all of your website's code, and all the changes made on the site.

Local Environment Setup: All development work should be done in a local environment - that way, everyone can test their changes and make sure everything works fine before updating the live website. Each developer clones the Git repository to their local machine, makes changes, and then pushes these changes back to the repository.

Use an Intermediate Server: Consider using an intermediate or staging server that does support Git. Developers can push their changes to the Git repository, and then the intermediate server can pull these changes from the repository. This server should be as close a mimic of the live environment as possible.

FTP Upload: Finally, from the intermediate server that now holds the most recent version of the website, you can use FTP to upload the files to the live server. This could be done manually, but there are also tools like lftp that can help automate this process.

Automating Deployment: If permissible within your budget and accordance to your infrastructure, you might even evaluate employing a continuous integration/continuous deployment (CI/CD) tool to orchestrate the steps mentioned above. These tools can give you control over the deployment pipeline, enable automated testing, and help ensure smooth and reliable deployment of changes.

Bear in mind, each time an FTP upload happens, it's important to make sure the live website isn't in the process of being accessed or updated - either by users (in cases where the site includes user-generated content) or other developers. This is to prevent any conflict or overwriting of data.

Finally, it's also worth noting that using FTP for deployment in this way isn't an ideal process due to its limitations (like difficulty tracking changes), but given your current constraints, it may be one of the more workable solutions. In the long term, consider moving to a hosting platform with better Git integration support if you continue to rely on Git for version control.


Beyond the steps I've described, here are further details and additional options for integrating version control with your hosting:

Use git-ftp: This is a Git command line utility that uses FTP as a transport protocol for deploying websites. This is most useful if your hosting provider only supports FTP. With git-ftp, you can push your Git commits to an FTP server. Here's a simplified typical flow:

Install git-ftp (available on most platforms)
Initialize git-ftp with your FTP details: git ftp init -u <ftpusername> -p - ftp://<ftphost>
Make your changes on the local copy of your repository and commit those changes: git commit -m "Commit message"
Push your changes via FTP: git ftp push -u <ftpusername> -p - ftp://<ftphost>
Implementing a Webhook: If your intermediate server supports it, you can set up a webhook to listen for changes in your main repository. Whenever changes are pushed to your repository, the webhook triggers an action on the intermediate server to pull the changes and deploy them via FTP to the live server.

Use CI/CD Tools: While there exists a plethora of CI/CD tools, Jenkins, TeamCity, Travis CI, or GitLab CI/CD can help automate your process flow from commit to deployment. You would create a pipeline/script that listens for changes in your codebase, tests your application, and if the tests pass, then automatically deploys your app to the server via FTP.

Explore Managed Hosting: You might want to consider a Managed WordPress Hosting service (in case you are using WordPress). Providers like WP Engine, SiteGround or Kinsta have Git integration and allow to create different environments (i.e. Production, Staging) easily.

Remember, it is crucial for your team to follow good practices of using Git, ensuring the master branch is always in a deployable state and using branches for new features or bug fixes.


If you need deeper integrations or more collaborative and automated workflow, here are additional methods and tools you can consider:

Use Deployment Services: There are several third-party services such as DeployHQ, FTPloy, or Buddy that can help automate the deployment of websites from a repository. Once your repository updates, these services can automatically deploy your site to your live server.

Switch to Git-based Web Hosting: If it is an option, consider switching to a git-based web hosting service such as Netlify, Vercel, or GitHub Pages. These platforms allow you to directly connect your Git repositories and they'll handle the deployment every time you push to your repository.

Docker and Web Hosting: Some web hosting companies support Docker. Docker is a containerization platform that allows you to package your application, along with all its libraries and dependencies, into a "container". You can version control the Dockerfile that describes how to build the container. This allows for consistent deployment between your development and production environments.

Serverless Platforms: If you're building a static website, or a website with serverless backend, you might also consider a serverless platform, like AWS Amplify or Google Firebase, which has built-in CI/CD features that directly connect to your Git repositories.

These few methods can offer a broader range of possibilities, and can also improve your overall workflow by streamlining the deployment process and reducing the risk of errors. Furthermore, they can give you more control over the environment that your website runs in and offer more advanced features that can help with the development process. However, migration to these platforms would require some additional time and resources for learning and setup.
  •  

QRY6GydayVercyday

It's really simple. Here's the procedure:
1. Get any VPS, even the cheapest one (if you don't have your own server).
2. Set up the necessary number of GIT repositories on the VPS.
3. Add a script hook to each repository that will automatically upload modified files to the desired FTP server. Based on the references provided, there are already available or partially ready-made solutions for this.

In other words, all you need to do is understand how the "hooks" mechanism in git works, as I understand it. Additionally, you can explore console-launched FTP clients or methods for mounting FTP as a file system. There are plenty of options, you just have to make a choice.
  •  

Edgar

Git does not support FTP protocol operations, so in the given scenario, the process should be structured as follows:

1) Begin by creating an empty repository on Bitbucket or GitHub (Note: private repositories require payment on GitHub).
2) Clone the repository to a local folder called X.
3) Configure an FTP client (e.g., FileZilla) to connect to folder X and the corresponding folder on the hosting server.
4) Update the site files on the hosting server.
5) Add the newly added files to Git using "git add".
6) Commit the changes using "git commit -a".
7) Push the changes to the remote repository on Bitbucket/GitHub using "git push".

Periodically, merge files from the local folder using FTP, and check for changes using "git diff". If the changes are valid, commit them using Git. If not, revert the necessary changes using "git checkout file_name". Commit again using "git commit", push the changes to the remote repository using "git push", and upload them from the local folder.

Additionally, it's important to ensure that the FTP client and Git are used effectively to manage the files and maintain a smooth workflow.
  •  

ichiro

Force your clients to upgrade to Git-friendly hosts with SSH or deploy scripts, otherwise, you're just wasting time on clunky Git-ftp hacks that break with every merge conflict.
Stop whining about server changes, if your team can't coordinate without nuking repos, maybe they're not cut out for dev.
  •  


If you like DNray forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...