R
R
RamonRa2019-01-16 22:55:40
git
RamonRa, 2019-01-16 22:55:40

How is the connection between the test and production sites to the same git repository?

Hello. Started learning git. I realized that this is very useful knowledge both in practice and when applying for a job. But one thing keeps bothering me.
Here I have a site called mysite.ru. This is a combat site/production. Naturally, on the server, the files of this site are located along the path /www/mysite.ru/ Now I want to add a version control system for the site. I have created a user

git config --global user.email "[email protected]"
git config --global user.name  "My UserName"

Then I created a .git repository
cd ~/www/mysite.ru
git init
git add .
git commit -m "Первый коммит"

Great, now I have a .git folder on the server.
But wait, it's wrong to make changes to the production site, you never know. Okay, now I'm creating a second site - dev.mysite.ru, right? And should I clone all files from mysite.ru to dev.mysite.ru? But then it turns out that there will be two .git folders - one on the main, and the other on the test sites. This means creating a separate branch for the technical site. But how will I push changes to dev.mysite.ru, and not to mysite.ru?
And in general, I didn’t quite understand how the version control system should work if you have only one site? Here are two programmers coding. How should they check their code - did you write a function and commit it to the main site? But you also need to push it. What if there were errors in the function? Rollback to a previous version?
I obviously do not misunderstand something in working with git, could you please point out where I am wrong?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Dart, 2019-01-16
@gobananas

Great, now I have a .git folder on the server

The git folder on the site should not be
Branches
You develop all features in separate branches, then everything is merged into dev, the dev branch rolls to dev.mysite.ru and is tested there. If everything is OK - merges with the master and the master rolls to mysite.ru
Push is done in a branch (branch)
For this, there is a dev-branch, test there, finalize, again roll out the dev-branch to the dev-site

A
Alexander, 2019-01-17
@NeiroNx

the test one is synchronized with all commits, and the working one is only with those where the release tag is. That is, I tested it - everything is OK, we create a release tag - and the scripts update the worker.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question