开发者

How to don't let file to be uploaded to repository?

Is it possible to prevent the specified file (path) from commiting to a repository?

For example, we need somepath/database_config.php not able to be committed.

I tried to use svn:ignore property, but it seems to be that it works only for working copies, not for repositories.

I've read svnbook.red-bean.com about this feature but I feel that my brain c开发者_StackOverflow中文版annot really understand why the things doesn't work like I want.


FYI: svn:ignore will only work if the file to ignore IS NOT in the repository.

What I do when adding configuration files in a repository, is create a template file that will be kept in the repository, and then ignore the configuration file specific to each developpers. So anyone who checkout the code would have to rename the template without the .template extension, and put its local configuration in it.

That way, every developper can have different configuration without affecting everybody.

ie: Template file: database_config.php.template

$config = array(
    'host'     => 'XXXX', 
    'db'       => 'XXXX', 
    'user'     => 'XXXX', 
    'password' => 'XXXX', 
);

Config file: database_config.php

$config = array(
    'host'     => 'XXXX', 
    'db'       => 'XXXX', 
    'user'     => 'XXXX', 
    'password' => 'XXXX', 
);

You would make these svn command to add in your repository.

// Add the template
svn add database_config.php.template
// Ignore the config file used by the system (Should not be in repository)
svn propset svn:ignore "config.php" .
svn commit


You can use the svn lock command to prevent a specific file or path from being altered in the repository. So, to prevent a certain file from ever being committed, you could simply commit an empty file (or that contains "do not commit this file - configs should only be made on the local machine"), and then locally alter your file to contain whatever content is necessary.

After you've locked the file, you can then restrict others from modifying the lock or the file itself, but at that point if your developers are fiddling with a file that obviously is intended to be locked, I'd start smacking them around and think about removing all their write access to that repository.

More information is available in the manual entry and more detailed documentation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜