Gitignore 不会忽略 Android 库中的一些构建文件
Gitignore not ignoring some build files in Android library
我有 an Android library,出于某种原因,我在 .gitignore
中指定的文件和文件夹没有被忽略。
我已经尝试修改我的 .gitignore
并关注 ,但这并没有改变任何东西。
这是我的顶层.gitignore
(也可以找到on the GitHub repo):
# Gradle files
.gradle/
build/
*/build/
# Local configuration file (sdk path, etc)
local.properties
# IntelliJ
*.iml
/.idea
module with the build
folder that isn't being ignored has the following .gitignore
:
/build/
我不确定为什么 build
目录没有被忽略,因为它在我的 sample app module, and in the top-level directory.
中被忽略了
另外,当我更新我的库版本时,我确实提交了对 build
目录中的一些文件的更改,如果这很重要的话。
你必须在构建之前删除你较低级别的 gitignore 中的第一个 /
,然后它就会工作。
此外,在顶层,你只需要这个:build/
然后不需要较低级别的 gitignore。
Stack Overflow 上的 This answer 帮助我解决了问题。
这是部分答案:
First commit any outstanding code changes, and then, run this command:
git rm -r --cached .
This removes any changed files from the index(staging area), then just run:
git add .
Commit it:
git commit -m ".gitignore is now working"
在您的项目中添加 .gitignore 文件,并设置以下行:
*.iml
.gradle
/local.properties
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/build
/captures
.externalNativeBuild
.idea
在我的例子中,.gitignore 文件被放置在 app 目录中,而不是 项目的根目录中 目录.
我通过以下方式解决了这个问题:
- 在 Android Studio 中打开项目视图
- 右键单击构建文件夹
- Select Git
- 添加到 .gitignore
我有 an Android library,出于某种原因,我在 .gitignore
中指定的文件和文件夹没有被忽略。
我已经尝试修改我的 .gitignore
并关注
这是我的顶层.gitignore
(也可以找到on the GitHub repo):
# Gradle files
.gradle/
build/
*/build/
# Local configuration file (sdk path, etc)
local.properties
# IntelliJ
*.iml
/.idea
module with the build
folder that isn't being ignored has the following .gitignore
:
/build/
我不确定为什么 build
目录没有被忽略,因为它在我的 sample app module, and in the top-level directory.
另外,当我更新我的库版本时,我确实提交了对 build
目录中的一些文件的更改,如果这很重要的话。
你必须在构建之前删除你较低级别的 gitignore 中的第一个 /
,然后它就会工作。
此外,在顶层,你只需要这个:build/
然后不需要较低级别的 gitignore。
This answer 帮助我解决了问题。
这是部分答案:
First commit any outstanding code changes, and then, run this command:
git rm -r --cached .
This removes any changed files from the index(staging area), then just run:
git add .
Commit it:
git commit -m ".gitignore is now working"
在您的项目中添加 .gitignore 文件,并设置以下行:
*.iml
.gradle
/local.properties
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/build
/captures
.externalNativeBuild
.idea
在我的例子中,.gitignore 文件被放置在 app 目录中,而不是 项目的根目录中 目录.
我通过以下方式解决了这个问题:
- 在 Android Studio 中打开项目视图
- 右键单击构建文件夹
- Select Git
- 添加到 .gitignore