Git for development and live websites

I use Git for both my development sites and live websites, and store them in my "dev" and "master" of my own branches. When I finish testing on the dev branch, I merge my changes with master, however there are some files that I need to save only for the dev branch / server.

those. index.php has a โ€œdevelopment serverโ€ message shown at the top of all pages, and Google Analytics tracking, and I want to keep it that way.

Also some configuration files that should not be changed during merging.

I use cherry picking, but it's slow and frustrating ... is this the best way to do this?

+4
source share
1 answer

You want to customize .gitignore files in your repo.

Basically, your configuration files should not be added to your repo. You can use the .gitignore file for this.

Tell me if there is a includes/ directory. There, create a .gitignore file with the following:

 config.php 

This suggests that config.php from this directory should not be added to the repo. Note: this will not work if the file is already added. If it has already been added, you must git rm the file.

Now, since the config.php will not exist in your repo at all, I would recommend creating config.sample.php , which looks exactly like you config.php , and is part of your repo. Thus, when you clone (or someone else clones) your project, they know exactly what should be in the configuration file.

+3
source

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


All Articles