Using GIT on live-servers
I’m kinda struggling now and I don’t know how to go on.
We recently switched from
GIT. Whenever we create a website, we want it to be under version-control.
For that case, on all our customer-webspaces, GIT is initially already installed. The idea is to develop locally, develop the site further and after finishing a change-request, “publish” this to the live server.
- Relative submodule URL to another GitLab group
- Gitlab - NoMethodError (undefined method `tag_names' for nil:NilClass):
- Git: How to checkout merge request locally, and create new local branch?
- Files missing in Gitlab after push
- Commit without add and how to see remote branch log
- Visual Studio 2015 git commit folder structure
For that case, we installed our own
gitlab-instance, where the code is deployed. Now, everything fine so far.
For security reasons, I read that you shouldn’t add config-files to the version-control. In my example, lets call the file
config.php. So I added this file-name to my
.gitignore and it works as expected. However,
if you want other to develop on the project as well, how do you handle it? Write in a
README on how to setup a
config.local.php and include that file in your main config file?
Next: There are certain files and folders which are needed to be there, even though they can be empty. As an example, we have a “temp”-folder. I need the folder to be there, but the content is irrelevant. I tried to add this line to
.gitignore, but that didn’t work:
From my understanding, that should just exclude files in the folder, not the folder itself, right?
Then again, and this is my last question: If for some reason the customer / owner changes stuff in his CSS-file(s), you are out of sync, right? You can’t just pull/fetch the recently checked in files without having problems (if you edited your css-file as well), since they would end up in a conflict. What is the way to go there? I read about a full-sync before, but that doesn’t protect me from getting into the same situation again, right?
If this is not the right plattform to ask, please tell me.
One Solution collect form web for “Using GIT on live-servers”
If you want an empty directory in your repository (temp, log) you must place a file in there which you add to the repository. Git does not track directories, only files.
You can have an empty
.gitkeep in every folder. But the name doesn’t matter at all. You could also use a
.gitignore in every empty folder.
There is nothing wrong with having config files in your repository. You just have to be careful about secrets.
Passwords for Database access should be secret of course, but depending on your situation so could addresses of services as well.
If you use GitLab CI for deployment you can read the configuration from Environment Variables and set these in GitLab (Project -> Settings -> Variables). These variables are not public.
The customer could have a custom branch which he than has to rebase every time you update the project.
You could implement custom css files in your project, meaning uploading the custom css file through a config/admin page.