I am using git
to organise my code in better way.
I have setup git
on localhost
and production server
There is a median GitLab
to store all commits and branches.
On the server
, I have setup two subdomains, one to host master
branch on app.example.com
and another one for dev
branch on dev.example.com
I have initialized and set up the same remote on both subdomains to pull master branch to app
and dev branch to dev
.
I want some files to be separate in all three places.
Like I have two files in my application database_config.php
and app.php
database_config.php
file contains the database credentials and since database credentials for localhost
, app
and dev
are different. I need it to be different and not be affected by merge, push and pull.
Similarly, I have app.php
through which debug
is enabled on localhost
and dev
but it will always be disabled on app
.
although I have included these files in .gitignore
file on localhost, it is not pushed to GitLab
. When in case of conflict I need to reset
HEAD on production which also deletes the both files on production because they does not exists on GitLab
repository.
How can I prevent these files from any action of the git and it will always be intact of any event?
When you add a file to .gitignore, it must be untracked. Remove it using git rm --cached database_config.php
.