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

          1928 у кіно

          Захаров Федір Захарович

          Ель Греко