How to use version control for your site on a normal hosting?

Welcome experts!
I want to translate the development/support of websites on git, but here is the problem almost all sites of the customers are on a regular hosting where you have access via ftp and work so not very convenient. I have long wanted to start to use git but how to do it with such sites you don't know, the problem is in the fact that they can work a few people and when casting it is necessary to consider possible changes already on the hosting.
Ie, to merge with it to create the repository on github or bitbucket particularly no problem, but how to fill in all the hosting so far for me is unclear.
July 2nd 19 at 13:49
8 answers
July 2nd 19 at 13:51
How to use version control for your site on a normal hosting?

Peredelnoj just. The recipe is as follows:
1. Take any can cheapest VPS (if your server is not)
2. There are setting up GIT repositories in the right quantity
3. In each repository, put the script hook, which will upload the changed files to the target FTP server (judging by the links above, such decisions are already in or finished or semi-finished form).

That is, You simply need to see the mechanism "hooks" Gita, as I see it. And even perhaps, to see the FTP client run from the console, or mechanism mount FTP as file system... the Options are many, You just need to choose.
Well, Yes, "peredele just" - overwrite files on the site with their versions and no conflicts.
If they are foolish someone else once ruled - not my problem... right? - chelsea13 commented on July 2nd 19 at 13:54
: I do not understand the essence of the problem. Exactly with the same probability and in a similar way, it is possible to overwrite files on the site, if there is FTP stood a GIT repository. If You have the 'master' branch any conflict - then it is a problem beyond the originally posed question. - Salvado commented on July 2nd 19 at 13:57
July 2nd 19 at 13:53
Surprisingly, some "normal hosting" (for example, beget, do not advertise) know how to use git. Usually this is done on request.
Check with tech support of the hosting provider.
+1 - chelsea13 commented on July 2nd 19 at 13:56
July 2nd 19 at 13:55
The problem described is only the tip of the iceberg.
You need to change the approach to the development.
While the client will climb into the code and FTP you will not be able to work normally with git.
While the client site is on shared hosting — you will not be able to work normally with git.

The problems begin with the divergence of the versions on the ftp and your local environment and the repository will be a conflict during database migration.

In General try to understand that something wrong and eventually comes to a normal solution :)
What do You mean by a normal solution? - chelsea13 commented on July 2nd 19 at 13:58
: Usually a normal solution is a result of the agreements with the client, taking into account his and your desires and expectations, and the optimal method of deployment, Assembly, etc.

But in the General case is:
- development only on the developer's machine, no ftp, etc.
- all changes to продt only through git. - Salvado commented on July 2nd 19 at 14:01
July 2nd 19 at 13:57
git does not support ftp Protocol. Therefore, in the above context, the work should be done as follows:

1) set up an empty repository in github or bitbucket (remember that github private repositories are paid).
2) Clone them yourself locally in folder X.
3) configure the ftp client (e.g. FileZilla) in the folder X and folder on the hosting.
4) Fill in hosting files sites.
5) Add in git appeared the files (git add).
6) of the Commit (git commit-a).
7) Send changes to a remote repository (bitbucket/github, git push).

Periodically via ftp merge the files to a local folder, using git diff look changes. If they are legitimate, then do git commit. If not, rolls need (git checkout file_name). Again fix (git commit) that are sent to remote repository (git push), perezalivat from the local folder.
Configured to work with git from the command line or have FileZill - use each time you send dannyh? - chelsea13 commented on July 2nd 19 at 14:00
: Working with git on the local machine. When changes are made, using FileZill copy the files back to the hosting. If the site something has changed, you need to FileZill via website files to copy themselves and to work again via git. Ie static copying files here and there will have to be done constantly. It only makes sense if it's a client's site which, in principle, no ssh access hosting (shared hosting) and you have to work with what we have. But whenever possible, you need from these hosters to leave. Now VDS is at the level of shared, and in our days there is not any sense to use shared if there is at least some technical knowledge. - Salvado commented on July 2nd 19 at 14:03
It's just something I vaguely remember about remote branches and the path type
There's, like, you could clone and fetch to do this, but push is not. In short, nothing has changed, in the course... - Bethel_Steuber87 commented on July 2nd 19 at 14:06
July 2nd 19 at 13:59
Hosting must be installed git. Poured also through the clone.
July 2nd 19 at 14:01
Poured myself a repo and fill in the FTP
July 2nd 19 at 14:03
If you are unable to find options on the Internet so far - it is better not to meddle.
And the lack of options.
Simple - I created a repository on git/bitbucket, set up accesses, etc. cloned-filled via FTP
More complicated hooks + services continuous integration.
Well, more harder hooks, settings on the server and SSH
July 2nd 19 at 14:05
1. Has everything you need for effective deployment (upload via ftp, sftp, sftp atomic...)
2. The ability to pre-build frontend (gulp, grunt... ) on a separate docker container
3. You can specify patterns to exclude files or folders to the unloading
4. Notifikacia through different services (e.g. slack) on the status of discharge

Minus: the service fee (15 bucks a month for 10 projects)

Find more questions by tags Organization of the workGitHosting