version control - Language agnostic way to remove sensitive information from files before committing to Git -


what recommended procedures automatically removing sensitive information files before committing git?

for example, have following in file called code.rb:

personal_stuff = "some personal stuff" 

how can automatically remove personal information code.rb before committing version control? solution should language-agnostic.

using "clean filter" specific files way go.

update example, demanded:

add "clean" filter local repository configuration, consisting of 1 call sed. path shell script or program consumes data on standard input , writes processed data standard output:

$ git config --add filter.classify.clean \     'sed -e '\''s!\<\(personal_stuff\s\+=\s\+\)"[^"]\+"!\1"secret"!'\' 

now register our filter applied files names match *.rb:

$ cat >.gitattributes *.rb    filter=classify ^d 

create couple of test files:

$ cat >test.rb aaa bbb         personal_stuff  = "sensitive data" ccc ^d $ cat >test.txt aaa xxx personal_stuff = "super secret" yyy ^d 

now add , commit them:

$ git add test.* $ git commit -q -m 'root commit' ... 

now see has happened contents of test.rb, is, blob in recorded commit contains:

$ git cat-file -p head tree 7adaac5cc23c69ff9459635d666ca63ffb9757aa author konstantin khomoutov <flatworm@...ourceforge.net> 1368453302 +0400 committer konstantin khomoutov <flatworm@...ourceforge.net> 1368453302 +0400   root commit  $ git cat-file -p 7adaa 100644 blob e49630236eb74d8c7ccbcccc83c7c18af0cb4b96    test.rb 100644 blob aecd9ade78e18d5b5ded99a1e41cf366fa52e619    test.txt $ git cat-file -p e496302 aaa bbb         personal_stuff  = "secret" ccc 

verify did not affect work tree:

$ cat test.rb aaa bbb         personal_stuff  = "sensitive data" ccc 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -