0

My query may not be obvious from the question title so I'd give an example,

Let say my html file index.html on Machine-1 is as follows:

MACHINE-1

<div class="col-xs-5 col-md-5 col-lg-3>
Lorem ipsum eget turpis urna curabitur fermentum ultricies enim, est magna at quam nam nisl praesent accumsan egestas, ut sit ac pulvinar tristique quisque tristique.</div>

I commit this and push to remote.

On my other machine I pull from remote but here I'd want the Sample data to be different say:

MACHINE-2

<div class="col-xs-5 col-md-5 col-lg-3>
Pharetra diam aenean vehicula sociosqu etiam at cubilia, mattis inceptos suscipit curabitur placerat ultrices, lorem consectetur lorem class curabitur donec.</div>

I commit this and push to remote.

When I pull from remote on Machine-1, the sample data "Lorem ipsum eget turpis ..." (in local repo) on Machine-1 should not be overwritten by sample data from Machine-2 "Pharetra diam aenean vehicula..."

Is there any command, workaround, setup to manage this scenario.

thanks

dkjain
  • 831
  • 1
  • 9
  • 36

1 Answers1

0

The question is, how is git to know what you consider repo-specific sample data; much less keep track of which sample data was pushed from which machine?

One solution is to source control a template

<div class="col-xs-5 col-md-5 col-lg-3>
${sample_data}</div>

Then you would have some process by which $(sample_data} gets replaced with the particular sample data for a machine or environment. (Typically this is done as part of a build process for the software.)

In Maven parlance, this is called "filtering" and the machine-specific values would be in "filter files". More generally you're interpolating values for placeholders, and you could think of the file containing the values as a machine-specific properties file. Whatever you call them, you could store each machine's data in a separate file in source control according to some convention (like /filter-files/machine1.filter might have values for machine1), so that the proper file can be selected when building for a particular machine/environment. Or the values could be stored outside source control and simply provided at build time.

This approach is more commonly applied to configuration files, rather than sample content for a div, but the principles are more or less the same. In that more general context, you can see where it might be useful to have some default configurations in source control, but for example keep the production system's values separate on a build server so that sensitive information needn't be put in source control.

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52