How to commit and fetch partial changes inside a properties file in Git? The Next CEO of Stack OverflowHow do I discard unstaged changes in Git?How to remove local (untracked) files from the current Git working tree?How to modify existing, unpushed commits?What is the difference between 'git pull' and 'git fetch'?How to undo 'git add' before commit?How do I undo the most recent commits in Git?How do I force “git pull” to overwrite local files?How do I delete a Git branch both locally and remotely?How to revert a Git repository to a previous commitHow do I rename a local Git branch?

What is the result of assigning to std::vector<T>::begin()?

How to safely derail a train during transit?

"In the right combination" vs "with the right combination"?

Is 'diverse range' a pleonastic phrase?

If/When UK leaves the EU, can a future goverment conduct a referendum to join the EU?

Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis

Do I need to enable Dev Hub in my PROD Org?

What can we do to stop prior company from asking us questions?

How to count occurrences of text in a file?

Why do airplanes bank sharply to the right after air-to-air refueling?

Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?

Complex fractions

Can I run my washing machine drain line into a condensate pump so it drains better?

How did people program for Consoles with multiple CPUs?

What does convergence in distribution "in the Gromov–Hausdorff" sense mean?

Can you replace a racial trait cantrip when leveling up?

Sending manuscript to multiple publishers

Real integral using residue theorem - why doesn't this work?

In the bitcoin scripting language, how can I access other outputs of the transaction? Or how else can I limit how the coins may be spent?

What was the first Unix version to run on a microcomputer?

How did the Bene Gesserit know how to make a Kwisatz Haderach?

Why do professional authors make "consistency" mistakes? And how to avoid them?

Why didn't Khan get resurrected in the Genesis Explosion?

How do I transpose the first and deepest levels of an arbitrarily nested array?



How to commit and fetch partial changes inside a properties file in Git?



The Next CEO of Stack OverflowHow do I discard unstaged changes in Git?How to remove local (untracked) files from the current Git working tree?How to modify existing, unpushed commits?What is the difference between 'git pull' and 'git fetch'?How to undo 'git add' before commit?How do I undo the most recent commits in Git?How do I force “git pull” to overwrite local files?How do I delete a Git branch both locally and remotely?How to revert a Git repository to a previous commitHow do I rename a local Git branch?










2















For example, in the repository I have a properties file like this:



database.url=https://localhost...
error.message=some message


So properties like database.url are used for local development environment and should never be fetched or committed. But others like error.message are general application configuration which do need to be fetched and committed all the time.



So every time this file changes, I always get this error:



error: Your local changes to the following files would be overwritten by checkout:
config/local.properties


To solve it I just save my local config in a temp file, then I perform a git checkout -- config/local.properties, after that I can now pull, checkout, merge, commit or whatever I need, and then I can now write again my local config.



It is extremely boring, time consuming and error prone. Is there a better way to do it? Split the file is not an option.










share|improve this question


























    2















    For example, in the repository I have a properties file like this:



    database.url=https://localhost...
    error.message=some message


    So properties like database.url are used for local development environment and should never be fetched or committed. But others like error.message are general application configuration which do need to be fetched and committed all the time.



    So every time this file changes, I always get this error:



    error: Your local changes to the following files would be overwritten by checkout:
    config/local.properties


    To solve it I just save my local config in a temp file, then I perform a git checkout -- config/local.properties, after that I can now pull, checkout, merge, commit or whatever I need, and then I can now write again my local config.



    It is extremely boring, time consuming and error prone. Is there a better way to do it? Split the file is not an option.










    share|improve this question
























      2












      2








      2








      For example, in the repository I have a properties file like this:



      database.url=https://localhost...
      error.message=some message


      So properties like database.url are used for local development environment and should never be fetched or committed. But others like error.message are general application configuration which do need to be fetched and committed all the time.



      So every time this file changes, I always get this error:



      error: Your local changes to the following files would be overwritten by checkout:
      config/local.properties


      To solve it I just save my local config in a temp file, then I perform a git checkout -- config/local.properties, after that I can now pull, checkout, merge, commit or whatever I need, and then I can now write again my local config.



      It is extremely boring, time consuming and error prone. Is there a better way to do it? Split the file is not an option.










      share|improve this question














      For example, in the repository I have a properties file like this:



      database.url=https://localhost...
      error.message=some message


      So properties like database.url are used for local development environment and should never be fetched or committed. But others like error.message are general application configuration which do need to be fetched and committed all the time.



      So every time this file changes, I always get this error:



      error: Your local changes to the following files would be overwritten by checkout:
      config/local.properties


      To solve it I just save my local config in a temp file, then I perform a git checkout -- config/local.properties, after that I can now pull, checkout, merge, commit or whatever I need, and then I can now write again my local config.



      It is extremely boring, time consuming and error prone. Is there a better way to do it? Split the file is not an option.







      git properties-file






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 14:57









      anfbaranfbar

      227




      227






















          1 Answer
          1






          active

          oldest

          votes


















          2














          How best to solve this depends on your build tooling, but the general principle is that local configuration values shouldn't be in your repo - and that includes the worktree unless you can use .gitignore to side-step them (which, since splitting the file is not an option, you can't directly do).



          Typically that means that you checkout to a source structure in which the properties file is just a template with placeholders for locally-defined values



          database.url=$DBURL
          error.message=Some message


          Of course you can't run that directly. Your build tooling combines this template with a locally-stored properties file (which either is outside the work tree or is .gitignored) to produce the real properties file (which, itself, is also either outside the git worktree, or .gitignored).



          Again there are many variations on this. If you already have a considerable build process that generates lots of new files (e.g. a java project, or a front-end project that's bundled and/or minified, etc.) then it may be as simple as having a target directory for the build separate from the worktree that's checked in (as per the typical Maven project structure, for example). Or if you want to execute the worktree in place, then the file you check in might be named my.properties.template and the build process might generate my.properties, so you .gitignore the my.properties.






          share|improve this answer























          • Looks like an interesting solution for a maven project, unfortunately I can't do that, I am using Hybris with Ant and I have some architectural constraints to perform a change like that

            – anfbar
            Mar 11 at 21:03











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55046784%2fhow-to-commit-and-fetch-partial-changes-inside-a-properties-file-in-git%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          How best to solve this depends on your build tooling, but the general principle is that local configuration values shouldn't be in your repo - and that includes the worktree unless you can use .gitignore to side-step them (which, since splitting the file is not an option, you can't directly do).



          Typically that means that you checkout to a source structure in which the properties file is just a template with placeholders for locally-defined values



          database.url=$DBURL
          error.message=Some message


          Of course you can't run that directly. Your build tooling combines this template with a locally-stored properties file (which either is outside the work tree or is .gitignored) to produce the real properties file (which, itself, is also either outside the git worktree, or .gitignored).



          Again there are many variations on this. If you already have a considerable build process that generates lots of new files (e.g. a java project, or a front-end project that's bundled and/or minified, etc.) then it may be as simple as having a target directory for the build separate from the worktree that's checked in (as per the typical Maven project structure, for example). Or if you want to execute the worktree in place, then the file you check in might be named my.properties.template and the build process might generate my.properties, so you .gitignore the my.properties.






          share|improve this answer























          • Looks like an interesting solution for a maven project, unfortunately I can't do that, I am using Hybris with Ant and I have some architectural constraints to perform a change like that

            – anfbar
            Mar 11 at 21:03















          2














          How best to solve this depends on your build tooling, but the general principle is that local configuration values shouldn't be in your repo - and that includes the worktree unless you can use .gitignore to side-step them (which, since splitting the file is not an option, you can't directly do).



          Typically that means that you checkout to a source structure in which the properties file is just a template with placeholders for locally-defined values



          database.url=$DBURL
          error.message=Some message


          Of course you can't run that directly. Your build tooling combines this template with a locally-stored properties file (which either is outside the work tree or is .gitignored) to produce the real properties file (which, itself, is also either outside the git worktree, or .gitignored).



          Again there are many variations on this. If you already have a considerable build process that generates lots of new files (e.g. a java project, or a front-end project that's bundled and/or minified, etc.) then it may be as simple as having a target directory for the build separate from the worktree that's checked in (as per the typical Maven project structure, for example). Or if you want to execute the worktree in place, then the file you check in might be named my.properties.template and the build process might generate my.properties, so you .gitignore the my.properties.






          share|improve this answer























          • Looks like an interesting solution for a maven project, unfortunately I can't do that, I am using Hybris with Ant and I have some architectural constraints to perform a change like that

            – anfbar
            Mar 11 at 21:03













          2












          2








          2







          How best to solve this depends on your build tooling, but the general principle is that local configuration values shouldn't be in your repo - and that includes the worktree unless you can use .gitignore to side-step them (which, since splitting the file is not an option, you can't directly do).



          Typically that means that you checkout to a source structure in which the properties file is just a template with placeholders for locally-defined values



          database.url=$DBURL
          error.message=Some message


          Of course you can't run that directly. Your build tooling combines this template with a locally-stored properties file (which either is outside the work tree or is .gitignored) to produce the real properties file (which, itself, is also either outside the git worktree, or .gitignored).



          Again there are many variations on this. If you already have a considerable build process that generates lots of new files (e.g. a java project, or a front-end project that's bundled and/or minified, etc.) then it may be as simple as having a target directory for the build separate from the worktree that's checked in (as per the typical Maven project structure, for example). Or if you want to execute the worktree in place, then the file you check in might be named my.properties.template and the build process might generate my.properties, so you .gitignore the my.properties.






          share|improve this answer













          How best to solve this depends on your build tooling, but the general principle is that local configuration values shouldn't be in your repo - and that includes the worktree unless you can use .gitignore to side-step them (which, since splitting the file is not an option, you can't directly do).



          Typically that means that you checkout to a source structure in which the properties file is just a template with placeholders for locally-defined values



          database.url=$DBURL
          error.message=Some message


          Of course you can't run that directly. Your build tooling combines this template with a locally-stored properties file (which either is outside the work tree or is .gitignored) to produce the real properties file (which, itself, is also either outside the git worktree, or .gitignored).



          Again there are many variations on this. If you already have a considerable build process that generates lots of new files (e.g. a java project, or a front-end project that's bundled and/or minified, etc.) then it may be as simple as having a target directory for the build separate from the worktree that's checked in (as per the typical Maven project structure, for example). Or if you want to execute the worktree in place, then the file you check in might be named my.properties.template and the build process might generate my.properties, so you .gitignore the my.properties.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 17:59









          Mark AdelsbergerMark Adelsberger

          21.9k11321




          21.9k11321












          • Looks like an interesting solution for a maven project, unfortunately I can't do that, I am using Hybris with Ant and I have some architectural constraints to perform a change like that

            – anfbar
            Mar 11 at 21:03

















          • Looks like an interesting solution for a maven project, unfortunately I can't do that, I am using Hybris with Ant and I have some architectural constraints to perform a change like that

            – anfbar
            Mar 11 at 21:03
















          Looks like an interesting solution for a maven project, unfortunately I can't do that, I am using Hybris with Ant and I have some architectural constraints to perform a change like that

          – anfbar
          Mar 11 at 21:03





          Looks like an interesting solution for a maven project, unfortunately I can't do that, I am using Hybris with Ant and I have some architectural constraints to perform a change like that

          – anfbar
          Mar 11 at 21:03



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55046784%2fhow-to-commit-and-fetch-partial-changes-inside-a-properties-file-in-git%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved