In general, there is a site on a separate hosting on which improvements are being made and a working site on another host, in both cases git is installed on the hosting.

When you get soda to a test site, then with the git branch command, I see that I am in the branch I need in which there are improvements, after I finished with the edits, I make commits, then git push origin my_test_branch .

After logging in to GitHub, and as I understand it, you need to compare the branches, the Pull requests button is responsible for this. I understand all the files that are affected and conflicts with the master branch. I understand that I merge the branches with the merge button, but there’s no here the question is how to see the changes on the working site now?

Need to log in via ssh and execute some git commands? if I type git branch, I don’t see my branch there because I didn’t create a repository on the hosting?

Help me figure it out, the project is real and needs to be done very urgently so I wrote it here, I work with git for only a few hours, I apologize if something is expressed incorrectly.

  • one
    Possible duplicate question: Setting up and deploying a project using Git - aleksandr barakin
  • there seems to me another problem, I want to understand how I connected to the work site, from the master branch with which I merged my own, that is, update the site so that the changes take effect - Sergey Zaigraev
  • Do not store the Git repository at all on your hosting. It takes up extra space, and as a result of your negligence, attackers can gain access to all of your code. Look better in the direction of rsync or git-sync . - Nick Volynkin

1 answer 1

The easiest workflow for loners:

  • go to ssh hosting

  • in the settings of the web server, deny access to the .git folder, or initialize the repository to a higher level (so that the directory is not available to clients through a browser)

  • git init && git add . && git commit -m "init"

  • on the local computer - git clone ssh://хостинг/путь/к/каталогу/c/.git/ make changes, then git add . && git commit -m "changes" && git push git add . && git commit -m "changes" && git push

  • add other repositories as git remote add upstream путь_к_гитхабу_или_другому_компу

You will have a default site with a default name called origin, for other remout names you choose.

Let's say someone changed the code on a githaba : you do it on a local computer:

git fetch upstream # pulled the changes from the github

git merge upstream/имя_ветки_с_изменениями # sdurgili to the current branch of change from the upstream ( githab )

if merdzh passed with conflicts - rule pens. either put git difftool (meld, etc.) / or intellijidea, where the merge is perfect

git push origin # push changes to hosting ,

if you wish, of course, you can add upstream github directly to the hosting and pull the changes right from it. in practice, this is inconvenient and besides, instead of two actual copies of the site code (on your own and on the hosting) you only have one (on the hosting)

google the rest

  • Changes are made on different hosting sites, ie servers, branches merged into an account on a githab, people have already worked and made changes to me, but it turned out that I really didn’t explain anything, and then the question is, it turns out if the master branch is updated, it remains for me I do not quite understand how to update the repository on the hosting of the working site - Sergey Zaigraev
  • updated the answer, look - strangeqargo
  • I apologize, but I hike something stupid, you gave a detailed and good answer, but I’ve got a little confused, can't you just download a branch update just by a hosting team? - Sergey Zaigraev
  • (about this in the last paragraph is written) you must first create an initialized repository on the hosting. add a remote to it - from where git will download updates. if you do it right on the hosting, bypassing the local computer - it may work. if conflicts arise, the site is likely to fall, and you have to do git merge --abort - strangeqargo
  • It is much easier to clone the version from the hosting, insert changes from the second server into it, and push it back to the hosting. - strangeqargo