I have this file. let's say x for this example inside folder y. I want to put a stub in the directory(P.S: I believe this github project does actually what I want to) , but only once. For this example it looks like this:
module.exports.id = "";
module.exports.secret = "";
module.exports.callback = "";
Those values should not be shared, that's why I only want to put the file(stub/empty) inside the repository once.
When I modify x again, changes should not be put in the git repository, but only inside directory y.
I hope I make sense and that this is also not a duplicate question. If that is the case I would love to know the stackoverflow topic which discusses this, so that I can close this topic.
I solve it the following way: I rename the file xto x-default and set git to ignore the file x (eg. by a .gitignore in the dir y). Every user who checks out the repo has to copy the checked out file x-default to x and set his values.
This has the advantage, that the file x-default can be updated with new values without problem (not overwriting the user's config) and because of x is ignored, the user's values do not get synced with other user's repos (like you want).
Your program should check for the existence of x and, if not there, give a hint to copy x-default to x and configure it (or do this automatically).
Edit
This works, but I believe it can be done cleaner.
Depends on what you want. You can also use this on your local repo:
git update-index --assume-unchanged x
So you commit the file once, and then run the command on the file if you do not want further changes to be commit. The problem here is, that other users will have to do the same once if they want to have it like you, or else their changes will get commited (and will overwrite yours or it will end in a merge conflict).
To undo this, just go
git update-index --no-assume-unchanged x
I'm not aware of an other solution, but maybe someone other.
Edit
P.S: I believe this github project does actually what I want to
This more looks like my first answer! They have a file example_keys_file.js and in the file .gitignore they ignore keys_file.js.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With