This question has already been answered:

I have a website on a hosting. I want to make it so that with the help of git it was possible to push data from the local machine directly to the hosting, without using gihub, respectively, so that the hosting has the ability to save data (fetch / pull).

PS: On the host that I use, you can use the terminal, right in the browser (the developers tried)

In short, I decided it this way: I created a 2 git repository on the server. One is in the working directory, the other is outside it: First in the usual way:

git init git add . git commit -m "First commit" 

Second to the directory above:

 git --bare init 

Then added this "bare" ("bare") repository as deleted to the first:

 git remote add hub ΠΏΡƒΡ‚ΡŒ/ΠΊ/bare-Ρ€Π΅ΠΏΠΎΠ·ΠΈΡ‚ΠΎΡ€ΠΈΡŽ git push hub master 

Then, on the local machine, I made ssh access to my hosting account by generating ssh-keygen keys and adding the public key to the authorized_keys file on the server.

Then I copied all the files with the command:

 git clone ssh://hostXXXXXXX@servXX.ΠΌΠΎΠΉ-хостинг.ru/home/hostXXXXXXX/ΠΌΠΎΠΉ-Π΄ΠΎΠΌΠ΅Π½/bare-Ρ€Π΅ΠΏΠΎΠ·ΠΈΡ‚ΠΎΡ€ΠΈΠΉ 

Then I made the necessary changes and started them in the standard way.

 git add . git commit -m "Second commit" git push origin master 

To copy the data to the working project, simply executed on a server:

 git pull hub master 

That's all!

Reported as a duplicate by members of aleksandr barakin , AK ♦ , Community Spirit ♦ 24 Oct '18 at 1:50 pm .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • one
    A very good way to make your site easy to break / merge sources. Do you need it? - KoVadim

2 answers 2

You make bare turnips in your home folder. You make access by keys in the SCS. You add remot on a computer in this turnip. Through git clone you create a working folder on the server.

  • 2
    I recommend to paint in more detail. While pulling more on the comment than on a full response. - AK ♦

If you have SSH access, then even a git-server is not needed on the hosting. The client can upload revisions to the repository using the file protocol.

If you want the files to be automatically deployed on the http-server with each push, then there is such a possibility.

In GIT, starting from version 2.3, it became possible to push into a non-bare repository.

If the receive.denyCurrentBranch updateInstead setting is set in the target repository, the local copy is automatically updated.

More details have already been given on the English version of StackOverflow.