سؤال

I have a project with some files which consist of config files with passwords and user specific data. We deploy this project to our server via git pull, and commit changes via git push from our computers.

I have noticed that git has git filter-branch commit-filer in which you can ignore password variables through sed command.

Does have any similar filter when I make pull?

I want to have on remote master origin file like this:

array(
'pass'=>'your_pass'
)

and when I make pull I want to ignore this line.

Does it have any better practice for sharing that type of files?

هل كانت مفيدة؟

المحلول

git filter-branch alters existing commits, it won't work automatically with new commits.

What you want is a hook.

However, you can't completely ignore the values in that file, since you can't alter committed objects without creating a parallel timeline. You can at most mask them in the working tree, setting up hooks that will always ignore the masked lines on checkout and commit. But that is very complex, and it will make things harder for developers.

A better alternative is to put such configuration in a separate file that is ignored by git, and each developer should maintain a local copy of that file with his own settings and passwords. It is never a good idea to put passwords on a public (or at least shared) repository. Passwords should always be private.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top