推送到 git 存储库时如何提取敏感信息?
我在类中的某处调用了一个函数,如下所示:
RLP.Unlock("User ID", new byte[] { ... });
数据是硬件制造商提供的每个用户信息,这本质上表明无论您使用该功能做什么都不是他们的问题。但我离题了。
最近,我不小心将这行代码提交到公共 GIT 存储库。这对我来说不足以重写历史,但我很想知道如何从其余代码中提取这部分代码,以便它不会出现在将来的提交中。
需要明确的是,我正在寻找一种将这两个敏感数据存储在此类中以外的位置的方法,以便我可以将它们添加到 git-ignore,同时仍然共享类的其余部分。
I have a function that I call somewhere within my classes that looks like this:
RLP.Unlock("User ID", new byte[] { ... });
The data is per-user information provided by the hardware manufacturers, which essentially says that whatever you use the feature for is not their problem. But I digress.
Recently, I accidentally committed code with this line to a public GIT repository. This doesn't concern me enough to rewrite the history, but I'd be interested to know how I can pull this section of code out from the rest so that it doesn't appear in future commits.
To be clear, I'm looking for a way of storing the two sensitive pieces of data somewhere other than in this class, so that I can add them to git-ignore, while still sharing the rest of the class.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您将这些数据分解为一个单独的数据文件,作为应用程序的输入提供,然后在单独的 git 存储库中跟踪该数据文件。 Git 本身并不是为了屏蔽存储库的某些部分而设计的,如果你试图强迫事情以这种方式工作,就会导致各种疯狂的结果。
I would recommend that you factor this data out into a separate datafile provided as input to the application, then track that one datafile in a separate git repository. Git itself is not designed for masking out parts of a repository, and all kinds of madness will result if you try to force things to work that way.