开发者

Selective git ignore by remote?

Say I have a project that is located on both a public open-source repo and a private development repo. Some files on the development repo would include stuff like database passwords and such that I don't want public. What would be the bes开发者_如何学Ct way to share the safe files between the two remotes? I'm thinking some kind of .gitignore file that is only applied to the public repo, is that possible? If not, any other suggestions?


Maybe put the more sensitive files in a different repo, submodule it in the original repo and give only your private developers the access to the private repo.


If there are really files, that should not leak to the public, for securities sake, don't put them in the repository, or encrypt the files with a password!

Best is, when you put unshared files in a separate repository that can live within the private development version:

BASE_DIR/.git
BASE_DIR/private/.git

Here BASE_DIR contains all the public files. BASE_DIR/private contains the private files.

When you just publish the data and not the repository (with all its history), you can simply

git --work-tree=PATH_TO_THE_PUBLIC checkout HEAD -- .

when a new version arrives.


Don't put passwords in source control, period. Just .gitignore them everywhere; distribute the private password file by other means.

(And no, there isn't a way to ignore files only in some repositories.)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜