configuration - Git: How to be sure untracked config files aren't silently deleted -
my situation is, suspect, pretty typical. i'm working on (young) project others using git version control. our project web app requires local configurations paths , keys spread across few different config files. thought way handle make template version of these config files , track in repository, not track our individual config files (recommended, e.g., here , here). make sure no 1 accidentally commits config file, added gitignore list.
but didn't realize @ beginning of our project -- after 1 person had started , others joined. 1 of config files tracked in commit history. our solution: remove index, of course!
but creates nasty gotcha! here's simplified scenario: have branch config file tracked.
git init # new repository echo 'file a' > a.txt git add a.txt git commit -m 'initial commit' then realize problem create new branch fix it: on new branch delete config file repository index (and add template version want track). gitignore original file.
git checkout -b testbranch cp a.txt a.template.txt echo 'a.txt' > .gitignore # ignore a.txt git add .gitignore git add a.template.txt git rm --cached a.txt git commit -m 'make template file a' ls # shows a.txt , a.template.txt still in working tree git status # shows working directory clean and of course make critical update config file.
echo 'super-critical config setting' >> a.txt then switch branches, merge, , boom!!
the config file gone, , changes made not tracked on any branch.
git checkout master ls # shows a.txt, not a.template.txt git checkout testbranch ls # a.txt gone!! git checkout master git merge testbranch master # a.txt gone forever!! having a.txt in gitignore file masks warning removing file index , switching branches overwrite or delete it. if carry out steps above, except ones gitignoring a.txt, won't allowed switch away testbranch without moving or deleting a.txt. if move different untracked file (a-copy.txt), checkout master , checkout testbranch again, you'll see a.txt gone, asked be, a-copy.txt still there.
that's part (might) understand. here's don't understand: else might cause trouble system? since git doesn't track individual files, chunks of content, there way super-critical config settings lost if particular file(name) never tracked in repository (and in particular never deleted index)? there way absolutely certain untracked (gitignored) data in repository never silently deleted?
and, record, here other options dealing local config i've come across. first 3 seem hacks prone forgetting/error, , next 2 require other file(s) configured locally , potentially lost. last 1 seems overkill, maybe it's not. if you're sure 1 of these best way deal config files, please explain why. if know of better, great!
git stashgit update-index --assume-unchanged- separate branches local settings, private each separate developer
- git attribute filter driver (smudge/clean scripts)
- "deployment" script, again separate , private each developer
- each developer maintains separate repository tracking config files, independently of main code repo
the general rule of thumb, sensitive information, is:
don't put sensitive information in git
no matter policy following (special branch sensitive stuff, or "git update-index --assume-unchanged" tactic), have risk push shouldn't.
slaven rezic mentions symlinks:
ln -s config.yaml.$username config.yaml but requires every user have proper config file, plus sensitive data in it.
if file must new evolutions, hard propagate them across each user's own config (sylinked) file.
the other option use content filter driver.

it will, on checkout:
- read template config file
- access sensitive data referential outside git repo (you define own policy here)
- generate (private, in "not versioned") config file, value placeholder replaced right data.
Comments
Post a Comment