How do we start using git when we have a dev and prod server?

I am introducing more advanced version control methods in our company, and I'm not quite sure how to start using git with the current situation that we have.

Now we have a development and production server. Changes are made directly on the development server, and after they are tested and ready, we will transfer them to the production server using drag and drop SFTP.

I would like to somehow implement git in this process (using GitHub), but I'm not sure where to start. Our development code base is very different from our production, because we have 10-15 projects under development and patches that cannot or should not be clicked.

How will we implement this so that we can start using git without having to map our dev to production database codes?

+5
source share
2 answers

Branch / Functional Experiments

First of all, if you have 10-15 projects in the development process, how do they now interact with each other?

Git solves this problem by providing branches. Therefore, instead of projects mixed with each other and sharing problems, each experiment will be divided into its own branch and will be based on the main branch or the dev branch. It also has the advantage that they merge much easier if it comes to it.

Central repository

So what is the recommended workflow? Just use one central git repository.

I would say build a central git repository from production code, and then port over the “experiments” that promise. Or experimenters combine them into new branches, and then help them complete them and push the branches up.

Then, to upgrade production, you need to pull it out of the main branch. To upgrade the development server, you must exit the development branch. No longer use SFTP. And experiments with functional branches can either be switched to development as needed, or even better, can only be used on local copies, which each developer launches and tests on his own.

Localhost development

It does not depend on git, in fact, but it is a significant part of the image, which seems to be missing, because y'all relied on SFTP, which is not versioned: if you have a version control system, the place no longer matters where it is placed cash desks and where commits are made, until they get to the central repository. You can now host a local version of the website to run your experiments. It will be fast. It will be available. And it will not break the development server or live server until you actually release the commits and update them so that you can experiment very freely and very hard, in local branches on the local machine. Assuming you work with websites, you can simply create a completely local copy with an alias in your hosts file. Therefore, I have a completely local website in http: //nw.local , which appears in the git repository folder. And if I want to experiment, I git branch experiment;git checkout experiment , and then hack and make commits, and if I like the results, I rearrange or merge the commits into the dev branch and push this. Then I often delete this branch and start a new branch with new or similar experimental features.

+5
source

You have a typical scenario and everything is under control. With git, all the more simplified.

First, I would suggest that you have a central git repository. Production and development servers can be installed as different branches of this central git repository. Now, since you always deploy production code using the production branch, you can call it the master branch of your central repo.

With this, you can go to the development server. First you create another branch called dev and base it on the master branch. It reflects the latest stable version of your product, and at any point in time, the dev branch should be the master + functions to be released. Using this structure, you need to establish a protocol for testing and deploying all your projects that are in the process.

Now let's say that function F is handled by employee X. Then X can create a new branch named branchFeatureF on its local one. This must be created from the origin/master branch, as this is a stable version. X has been working on its function for several days and feels ready to test. Ok, now click this on the dev branch. Its as good as clicking on master , but since you are still in the testing phase, you are working on the dev branch to test it before it goes to master .

All QA runs in the development branch. After fixing the errors, the F function is now ready for release, so the time to merge the branchFeatureF branch into master and deploy your code is amazing.

Now the master has an F function, so before you check another F function with another X 's employee on the dev branch, you pull the changes from the last master with the F function and check that. Of course, if conflicting elements conflict with each other, F and F can work simultaneously with X and X by clicking on the dev branch and simultaneously testing their respective functions.

In essence, you give enough freedom to all your colleagues to work on their functions, asking them to create their own function branches, but making sure that they always click on the dev branch and that the dev branch is always up to date with the last wizard. This ensures that time is not wasted by figuring out any merge conflicts when merging branches. You, as the repo developer, will take responsibility for merging the approved branches of functions approved by QA in mastery and deploying code in production. Do not bother with the master branch.

+1
source

Source: https://habr.com/ru/post/1200690/


All Articles