Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 864139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:25:35+00:00 2026-05-15T09:25:35+00:00

I have been studding GIT for the last couple of weeks in an attempt

  • 0

I have been studding GIT for the last couple of weeks in an attempt to get my team’s code under control.
Unfortunately the code we work with is a proprietary language with some peculiarities which is keeping me from finding a practical enough workflow to be implemented. Still, I’m probably not aware of all GIT’s capabilities so I ask you guys for suggestion. I will divide this post in three: 1) how are my files; 2)the workflow we’ve figured so far; 3)options I reckon for the future.

My Files then;

As I said this is a proprietary script language, in which within the code itself you will find tags regarding configurations (servers, DB’s and other stuff). It might sound strange, I know, but technically this code is a big complex configuration file. Well, it can not be changed, for now lets just leave it.

I also have two different environments: dev and prod, and I guess it’s uses are evident. Due the odd way the code is thought, if you compare the script in dev to the same one in prod you would see:

prod:

CodeCode += Code(0)
Code{1} ...
CodeConfig = "ConnectionToProducionDB"
SomeMoreGenericCode.doSomething()
(...)

And in dev it would look like:

CodeCode += Code(0)
Code{1} ...
CodeConfig = "GoToSomeDevDB"
SomeMoreGenericCode.doSomething()
(...)

That would be it regarding the files.

Now, what have been figured;

At first glance, it seemed for me a classical lets branch it situation and so I’ve done.

[create a folder and init it]
[copy my code from production and add/commit it]
$ git checkout -b dev
[change these lines with 'CodeConfig' to the dev settings]
[go happy coding and commiting]

After a while, coding and tests are done and it is time to merge into production. That’s when the problem starts.

A simple git merge dev (from my master branch) will merge the codes mostly ok, but the configs will be also transferred to the master branch, as from GIT’s POV this is one of the updates in the code itself. While in this short code it wouldn’t be a problem, in the real situation I might have re-configured ten or twenty sources and rolling back one at time isn’t quite a pleasant (nor a reliable) task.

Of course, when using branches I do want to be able to merge my code in order to keep my commit history and comments. I just need it to be done in a more customized way…

I have tried a couple different things to work this out, but had no success. Seems that GIT’s merge is just too smart for me 🙁

For instance, *.xml merge=Unset into my .gitattributes file. Or a custom merge driver into ~/.gitconfig trying to cause the auto-merge to fail (not sure if I got that right though).

Possible solutions I thought;

As I said, I am probably not aware of all GIT’s functions, so my options are bound by those I know. I appreciate your innovation 😉

I though the simplest way would be if I could disable any auto merging and do it all manually (the codes aren’t so large, and I’d have to look into it anyway). After that I’d create a simple merge driver that would pass all the code changes (not only the conflicts) to something like WinMerge or Kdiff3 where I’d get the job done. Unfortunately I didn’t manage to get it this way yet.

My last attempt resulted in a lengthy and unpractical workflow, but I’ll write it here so you can have an idea of my goal.

  1. init repo proj1
  2. copy prod files
  3. first add/commit
  4. $ git checkout -b dev
  5. configure dev settings
  6. code/commit dev cycle
  7. copy dev files to tmpDevDir
  8. $ git checkout master
  9. use WinMerge to compare tmpDevDir against proj1[master branch] and apply only desired changes
  10. commit proj1[master branch]
  11. $ git merge dev
  12. merge conflicts where needed
  13. $ git diff HEAD HEAD^ to review merge result and revert the merged configs
  14. $ git commit -am 'final commit for the production code'

And well… not nice.

Would anyone have ideas for a more practical workflow or other commands which would help this out?

thanks a lot,

f.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:25:36+00:00Added an answer on May 15, 2026 at 9:25 am

    It a classic “config file” situation (even if your files are not exactly config file).

    The usual solution is to:

    • put only variable names in your code
    • extract the values specific to each environment in their own files
    • version a script able to generate the actual code (the one in which variable names have been replaced with their values depending on the current environment)
    • set a filter driver (see Git ProBook) to automate the variable substitution (meaning no “new files” are created: only the current code is modified on git checkout — variable replaced by values –, and “cleaned” on git commit — values replaced by variables, and values put back in a separate config file if they have been modified)

    alt text

    That way, you don’t have necessarily to create separate branches just because you have separate values in some files.
    No complex merges, copy between branches and so on.

    Just:

    yourCode1.code
    yourCode2.code
    ...
    yourCoden.code
    devValues.txt
    prodValues.txt
    scriptPutValuesInCode.sh
    scriptCleanCodeFromValues.sh
    

    and a filter “smudged clean”

    *.code  filter=setOrCleanValues
    
    git config --global filter.setOrCleanValues.smudge /path/to/scriptPutValuesInCode.sh
    git config --global filter.setOrCleanValues.clean /path/to/scriptCleanCodeFromValues.sh
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Over the last few weeks I have been studying the MVC design pattern for
Hey peoples, I've been studying Java for a couple of weeks, and have decided
First of all, i have been studying Java for only the last couple of
I have been working with JQM for a couple of weeks and after studying
Have been working on this question for a couple hours and have come close
I have been studying .NET 4.0 Code Contracts and looking on stackoverflow as well
I have been studying (old) 3D rendering techniques for the past weeks and think
I have been studying the bonjour/NSStream sample code from lecture #17 of Stanford's CS193p
I have been studying this code to generate random text: from collections import defaultdict,
I have been studying testOnDemandRTSPServer code and I want to do streaming by taking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.