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?
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
add a comment |
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
add a comment |
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
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
git properties-file
asked Mar 7 at 14:57
anfbaranfbar
227
227
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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