How can I add a xml file from /res/values to my gitignore in my Android project? -


i added separate xml file /res/values folder contains secret api key app uses.

api_key.xml

<?xml version="1.0" encoding="utf-8"?> <resources>     <item name="api_key" type="string">my_key</item> </resources> 

now exclude git. how can that?

i added line .gitignore file in project root

/app/src/main/res/values/api_key.xml 

but not work. file still appears on github after pushing project content.

git's ignore system applies files aren't yet tracked. because you've committed file, ignoring won't anything.

  1. first, , importantly, invalidate api secret key.

    you've published it, , there nothing can make key secure again. generate new key use going forward. do not skip step. there bots purpose in life leaked api keys on github.

  2. remove file git, using git rm --cached app/src/main/res/values/api_key.xml root of repository. remove file local repository, leave in local working copy. because file no longer tracked, ignore take effect.

    update file new api key step 1.

  3. optionally, add placeholder file, e.g. app/src/main/res/values/api_key.xml.sample, repository. file should not include api key, rather should skeleton of file need, e.g.

    <?xml version="1.0" encoding="utf-8"?> <resources>     <item name="api_key" type="string">dummy_api_key</item> </resources> 

    developers work on project should encouraged copy file to api_key.xml , add proper api key.

  4. push github. existing file removed, , history remain in repository. that's okay, because you've invalidated leaked api key.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -