【发布时间】:2019-09-16 15:55:00
【问题描述】:
我有一堆不应该受版本控制的文件。但是,如果我不将它们置于版本控制之下,那么我的构建就会失败。由于这些文件包含键/值内容,我添加了这些文件,但用假值替换了实际值。因此,我能够通过我的构建,而且我没有 VC 下的那些实际键/值。我将此更改提交给 VC。我还将这些文件的列表放在 .gitignore 文件下,如下所示:
/app/src/main/assets/*.json
/app/src/main/assets/*.kt
现在的问题是,为了测试我的更改,我需要将那些假文件/值替换为实际文件/值。但是,通过这样做,当我运行 git status 时,我会在更改文件列表中获得这些文件。
我清楚地将它们添加到.gitignore 下,为什么我又在这里看到它们?这是我看到的:
hesam(dev)$ git status
On branch dev
Your branch is up to date with 'origin/dev'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: app/src/main/assets/EmergencyContacts.json
modified: app/src/main/assets/LocationOfSites.json
modified: app/src/main/assets/LocationOfHospitals.json
modified: app/src/main/assets/LocationOfOffices.json
【问题讨论】:
-
.ignorefile你的意思是.gitignore? -
changes not staged for commit表示您的文件已被跟踪。跟踪的文件永远不会被忽略!只能忽略未跟踪的文件。 -
@Blackbelt,啊,是的。对不起,我错了。我更新了我的问题。
-
@torek,啊,我不知道。请把它写成答案,然后我很乐意接受。另外,如果您能告诉我在这种情况下我该怎么办,那就太好了?如果正在提交这些文件,我可以有一个提交失败的脚本吗?
标签: android git android-studio gitignore