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

 

git on webhosting

Started by evons, Dec 25, 2022, 01:47 AM

Previous topic - Next topic

evonsTopic starter

Greetings, developers! After watching video tutorials and reading books, I'm interested in delving into git. However, some aspects are still unclear to me.

I currently work on hosting beget.ru and edit files through FTP. Occasionally, someone else may also connect and make changes, but it's been a messy process. How can I transition to using git?

To begin with, I connected via ssh, navigated to the working directory and initiated git with git init. Am I correct in thinking that this will create a repository that I can connect to? Will I need to add folders and files to the repository, then connect from my computer via git clone to work on those files before doing a git push?

Alternatively, could the remote repository be hosted on platforms like GitHub, where I can upload all my changes and then pull them onto the hosting platform?
  •  


Dmitry328

It's advisable to have a designated repository on a specialized GIT server, such as GitHub, GitLab or Bitbucket.

Before commencing work, each colleague must perform a git pull to obtain a local copy of the repository. Upon completion of their tasks, they must then do a git push to transfer data from their local repository to the repository on the respective GIT servers.

Additionally, there are situations when collaborators may accidentally overwrite each other's work, which can be resolved through either git merge or Git branches.

It's important to note that uploading changes from GIT (from the Bitbucket/GitHub/GitLab server, not from the local repository) to the deployment server (FTP in your scenario) is a separate operation altogether.
  •  

chrishubber

A solution would be to use an intermediate provider such as Github or Bitbucket, or alternatively, install it on a personal server. GitLab is an example of such an option, which allows you to run the service on your own server by visiting https://about.gitlab.com.
  •  

jobtardis

Git Remote Hosting can be utilized if you are currently working with a remote repository on platforms such as GitHub (github.com) or BitBucket (bitbucket.org). In this scenario, you would transfer the changes made to a remote repository. Plesk receives these alterations from the remote repository and proceeds to deploy them on your website.


  •  

sigma-sem

Here's an in-depth guide on how you can smoothly make the transition:

1. Setting up Git on your hosting platform:
  - Connect to your hosting server via SSH. This secure connection will allow you to interact with your server's command-line interface.
  - Once connected, navigate to the directory where your project files are located. This is usually the root directory of your website.

2. Initializing the Git repository:
  - Use the command `git init` to initialize a new Git repository in the current directory on your hosting server. This will create a hidden folder named ".git" which contains all the necessary repository files.

3. Managing the repository:
  - After initializing the repository, you can start tracking changes to your project files. Use the `git add` command to stage the changes you want to include in the next commit. Follow this with `git commit` to save a snapshot of the staged changes to the repository.

4. Connecting from your computer:
  - To work on the files locally, use the `git clone` command on your computer to create a copy of the repository from your hosting server. This will download all the project files and the full history of the repository to your local machine.

5. Pushing changes to the remote repository:
  - After making changes locally, use `git push` to upload the committed changes from your computer to the remote repository on your hosting server. This keeps the server's repository up to date with your local changes.

6. Using remote repositories like GitHub:
  - Absolutely! You can utilize platforms like GitHub, GitLab, or Bitbucket as your remote repository. Create a repository on one of these platforms and then link it to your local repository. After that, you can push your changes to the remote repository, and even set up automated deployment options to pull the changes onto your hosting platform.
  •  


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