How to commit and fetch partial changes inside a properties file in Git?2019 Community Moderator ElectionHow 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?

Welcoming 2019 Pi day: How to draw the letter π?

Counting models satisfying a boolean formula

Meme-controlled people

Is it good practice to use Linear Least-Squares with SMA?

How difficult is it to simply disable/disengage the MCAS on Boeing 737 Max 8 & 9 Aircraft?

Violin - Can double stops be played when the strings are not next to each other?

How to pronounce "I ♥ Huckabees"?

Why Choose Less Effective Armour Types?

I am confused as to how the inverse of a certain function is found.

Why does a Star of David appear at a rally with Francisco Franco?

Is it normal that my co-workers at a fitness company criticize my food choices?

combinatorics floor summation

My adviser wants to be the first author

World War I as a war of liberals against authoritarians?

Is "upgrade" the right word to use in this context?

Knife as defense against stray dogs

Bach's Toccata and Fugue in D minor breaks the "no parallel octaves" rule?

Can I use USB data pins as power source

ERC721: How to get the owned tokens of an address

PTIJ: Who should I vote for? (21st Knesset Edition)

Could the Saturn V actually have launched astronauts around Venus?

The German vowel “a” changes to the English “i”

Why is a white electrical wire connected to 2 black wires?

Shortcut for setting origin to vertex



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



2019 Community Moderator ElectionHow 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.7k11321




          21.7k11321












          • 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

          Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

          Can't find variable: document ReactNative Js2019 Community Moderator ElectionReactNative: how to center text?Can't find variable: navigate - ReactNative navigationReact Native error: “Can't find variable: TouchableHighlight”How to use Expo.DocumentPicker.getDocumentAsync properly. [Expo] [ReactNative]Can't find variable: regeneratorRuntime (ReactNative)Reactnative Expo It is advisable for a StartUp?Can't find variable : Self / Can't install firebaseNPM Install Error in installing ReactNative CLIContacts Displaying in App using ReactnativeFacebook login error: can't find variable: Alert

          Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices