Using GIT on live-servers

I’m kinda struggling now and I don’t know how to go on.
We recently switched from SVN to 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.

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:

/temp/*

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.
Thanks

  • How to connect Visual Studio 2015 to an existing Gitlab project?
  • Unable to push code to gitLab it was workig an hour before
  • Can't start gitlab service
  • Will git cherry-pick on tag affect original tag?
  • Git command to get SVN style diff; modified file list between revisions
  • Push to GitLab repository within CI server (deploy keys)
  • Gitlab prompts for git password when cloning a git repository
  • unable to create user with API in Gitlab server
  • One Solution collect form web for “Using GIT on live-servers”

    Question 1:
    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.

    Question 2:
    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.

    Question 3:
    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.

    Git Baby is a git and github fan, let's start git clone.