2

I want to make an java application. This is stored on gitHub (so uses git for versioning). Now this programm uses apikeys in example from Google. I want to hide this Api key in the versioning system (so that no one other can use it).

I've read something about the .gitignore file, but i don't want to delete the whole file from versioning. I only want to hide the apiKey from others to see.

I read following thread and I think this is what I'm searching for, but I really have no idea how to do this.

Can git automatically switch between spaces and tabs?

4

1 回答 1

2

您不能对文件进行版本控制并对其他人隐藏。提交的 ID 部分基于提交文件树的 ID,它基于该树的内容——文件名和内容。如果你改变了一个文件的内容,你就改变了它在 Git 中的身份。当你改变它的身份时,你改变了它所包含的树的身份,一直到提交。

简而言之,没有。包含此文件的每个提交的 ID 将基于该文件的内容。向有权访问存储库的其他人隐藏文件的唯一方法是从一开始就永远不要将其添加到存储库中。

(如果您尚未发布存储库,您可以使用 重写历史记录git filter-branch以删除所有出现的文件。请注意,如上所述,这将更改许多提交的身份。)

于 2011-08-28T08:10:40.317 回答