1

My question is not a technical one, but more like advisory from a more experienced GIT user.

So, our team has 2 directories in the server, one is for staging where we test the changes we make, and the other one is the public directory where we can find the files for the live website. Until now, we were using FTP to update the files on the public directory, but now we switched to GIT so that we can track our changes.

I set up the GIT environment with a hook so that when we push some changes from the staging repository localy, they are automatically deployed to the staging directory on the server. Now I want to make the same to the public directory but some files (maybe I will also have a problem with the Work Tree?) between Staging and Public are different and I also don't want to lose the commits already made in the local staging repository.

What do you think is the best and most efficient way to do this transission?

My idea of the procedure is this:

  1. Clone the public project hosted on the server,
  2. Fetch or merge my local repository to the cloned respository from the server(public)
  3. Now I have a single repo from where I can push my changes to server and force push(at the beginning) to the staging.

Does this sound ok to you?

  • In a word, branch. This is the kind of situation that branches are great for, *however*, your staging and production setups should be _identical_. – Luke Briggs Feb 01 '17 at 16:49
  • @LukeBriggs Thank you for the tip! Could you describe briefly a basic model like that? – Kiriakos Papachristou Feb 01 '17 at 21:27
  • Sure - I'd imagine the files that are different are config files? Change whatever necessary to make the config (and as much as possible) the same. If that's really not possible then your repo would be the testing code, optionally with a `stable` branch which your staging server checks out (or checkout `master`). Then another branch off your stable (e.g. `production`) would contain the necessary modified files. – Luke Briggs Feb 01 '17 at 21:53

1 Answers1

0

You could use a content filter driver in order to generate those files automatically on checkout.

See "Best practice - Git + Build automation - Keeping configs separate": you would version afile.staging, afile.prod, but generate afile on checkout depending on your current environment.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250