{"id":33661,"date":"2023-02-11T10:27:55","date_gmt":"2023-02-11T04:57:55","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/"},"modified":"2023-02-11T10:27:55","modified_gmt":"2023-02-11T04:57:55","slug":"solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/","title":{"rendered":"[Solved] How do store sensitive files in my repo without tracking it? [duplicate]"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-66360878\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"66360878\" data-parentid=\"66356206\" data-score=\"1\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>The answer to the question in the subject line:<\/p>\n<blockquote>\n<p>How do store sensitive files in my repo without tracking it?<\/p>\n<\/blockquote>\n<p>is: <strong>you don&#8217;t<\/strong>.<\/p>\n<p>The reason is simple: Git builds new commits from whatever is in Git&#8217;s <em>index<\/em>.  The index, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.dictionary.com\/browse\/aka\">a.k.a.<\/a> the <em>staging area<\/em>, holds the copies of files that will go into your next commit.  It&#8217;s initially filled in by copying out the files from the <em>current<\/em> commit.  These same files are copied to your <em>working tree<\/em> so that you can see and work on them.<sup>1<\/sup>  Then, as you modify your working tree copies, you run <code>git add<\/code> to copy the working tree versions back into Git&#8217;s index, so that the proposed <em>next<\/em> commit is also updated.<\/p>\n<p>A <em>tracked file<\/em> is one that is in Git&#8217;s index.  It is therefore proposed to be in your next commit.  If you untrack the file (by removing it from Git&#8217;s index), it is proposed that the next commit should omit that file, i.e., the file is deleted between the two commits.<\/p>\n<p>The answer\u2014well, <em>an<\/em> answer\u2014to the question inside the text:<\/p>\n<blockquote>\n<p>I prefer to store the json file with empty fields in my repo so the credentials can be later filled out either by my build script, or filled out by another developer after the repo is initialized:<\/p>\n<pre><code>{\n     \"username\": \"\"  \/\/ to be filled by build or user\n     \"password\" : \"\"  \/\/ ditto gitto\n}\n<\/code><\/pre>\n<\/blockquote>\n<p>is to use Git&#8217;s <em>smudge<\/em> and <em>clean<\/em> filter mechanism so that the <em>stored<\/em> file, in Git, omits the sensitive data, while the <em>working tree<\/em> copy of that same file\u2014the data that you can see in a file-viewer and edit in an editor\u2014shows it.<\/p>\n<p>The smudge and clean filter mechanism is a little tricky, and carelessness can result in the sensitive data winding up in the repository.<\/p>\n<blockquote>\n<p>I&#8217;ve encountered a few ways to achieve with Git in the past, but they all require the user to actively perform additional steps &#8230;<\/p>\n<\/blockquote>\n<p>Setting up the smudge and clean filters has this same problem.  Once set up, though, the <em>clean<\/em> filter can take the working tree copy, which has the sensitive data, and strip that sensitive data <em>out<\/em> of the file-contents as the file is copied from your working tree into Git&#8217;s index.  So the proposed <em>next<\/em> commit does not have the sensitive data.  The <em>smudge<\/em> filter can put the sensitive data back into the file as it&#8217;s copied from a commit, or from Git&#8217;s index, to your working tree copy.  (Of course your smudge filter needs to <em>get<\/em> the sensitive data <em>from<\/em> somewhere.  So: where are you keeping the actual data?  Why not keep it there and <em>only<\/em> there?<sup>2<\/sup>)<\/p>\n<p>In general, then, the right answer is: don&#8217;t put this stuff in the repo at all.  Instead of a json file that needs to be filled-in, supply an <em>example<\/em> (or &#8220;template&#8221;) json file, or keep that data in some other file.<\/p>\n<hr>\n<p><sup>1<\/sup>The difference between Git&#8217;s index copy of a file, and your working tree copy of the same file, is &#8230; well, see the smudge and clean filter stuff as well, but the important difference to <em>Git itself<\/em> is that the copy in Git&#8217;s index is already in the special format that Git uses to store files.  This format is compressed and de-duplicated and does not use the storage system that your OS uses.  It can therefore hold files whose names your OS cannot pronounce, as it were, depending on your OS.  It&#8217;s also very fast to commit: it doesn&#8217;t require scanning through the data to compress and de-duplicate it, for instance.<\/p>\n<p><sup>2<\/sup>Convenience, stubbornness, spite, obstinacy &#8230; there are <em>lots<\/em> of good reasons! ?<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">4<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved How do store sensitive files in my repo without tracking it? [duplicate] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] The answer to the question in the subject line: How do store sensitive files in my repo without tracking it? is: you don&#8217;t. The reason is simple: Git builds new commits from whatever is in Git&#8217;s index. The index, a.k.a. the staging area, holds the copies of files that will go into your next &#8230; <a title=\"[Solved] How do store sensitive files in my repo without tracking it? [duplicate]\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/\" aria-label=\"More on [Solved] How do store sensitive files in my repo without tracking it? [duplicate]\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[329,4568,5043],"class_list":["post-33661","post","type-post","status-publish","format-standard","hentry","category-solved","tag-git","tag-repository","tag-tracking"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] How do store sensitive files in my repo without tracking it? [duplicate] - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] How do store sensitive files in my repo without tracking it? [duplicate] - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] The answer to the question in the subject line: How do store sensitive files in my repo without tracking it? is: you don&#8217;t. The reason is simple: Git builds new commits from whatever is in Git&#8217;s index. The index, a.k.a. the staging area, holds the copies of files that will go into your next ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-11T04:57:55+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] How do store sensitive files in my repo without tracking it? [duplicate]\",\"datePublished\":\"2023-02-11T04:57:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/\"},\"wordCount\":630,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"git\",\"repository\",\"tracking\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/\",\"name\":\"[Solved] How do store sensitive files in my repo without tracking it? [duplicate] - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2023-02-11T04:57:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] How do store sensitive files in my repo without tracking it? [duplicate]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] How do store sensitive files in my repo without tracking it? [duplicate] - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] How do store sensitive files in my repo without tracking it? [duplicate] - JassWeb","og_description":"[ad_1] The answer to the question in the subject line: How do store sensitive files in my repo without tracking it? is: you don&#8217;t. The reason is simple: Git builds new commits from whatever is in Git&#8217;s index. The index, a.k.a. the staging area, holds the copies of files that will go into your next ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/","og_site_name":"JassWeb","article_published_time":"2023-02-11T04:57:55+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] How do store sensitive files in my repo without tracking it? [duplicate]","datePublished":"2023-02-11T04:57:55+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/"},"wordCount":630,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["git","repository","tracking"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/","url":"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/","name":"[Solved] How do store sensitive files in my repo without tracking it? [duplicate] - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2023-02-11T04:57:55+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-do-store-sensitive-files-in-my-repo-without-tracking-it-duplicate\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] How do store sensitive files in my repo without tracking it? [duplicate]"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/33661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=33661"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/33661\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=33661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=33661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=33661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}