如何忽略 .gitignore 中的确切文件名? (没有子串)
How to ignore exact filenames in .gitignore? (without substrings)
假设我有一个名为 secrets/passwords.txt
的包含敏感信息的文件。
我希望 git 忽略此文件,但上传另一个名为 /secrets/passwords.txt.template
的文件,其中包含没有密码本身的密钥名称。
如何在 .gitignore
中编写忽略 secrets/passwords.txt
但包含 secrets/passwords.txt.template
的逻辑?
只需添加您要忽略的文件,例如:
secrets/passwords.txt
请注意,为了明确否定忽略(在您的情况下不需要),您可以使用 !
前缀,例如:
!secrets/passwords.txt.template //! will negate the instruction
假设我有一个名为 secrets/passwords.txt
的包含敏感信息的文件。
我希望 git 忽略此文件,但上传另一个名为 /secrets/passwords.txt.template
的文件,其中包含没有密码本身的密钥名称。
如何在 .gitignore
中编写忽略 secrets/passwords.txt
但包含 secrets/passwords.txt.template
的逻辑?
只需添加您要忽略的文件,例如:
secrets/passwords.txt
请注意,为了明确否定忽略(在您的情况下不需要),您可以使用 !
前缀,例如:
!secrets/passwords.txt.template //! will negate the instruction