Git 忽略 Android Studio 项目 libs 文件夹

问题描述 投票:0回答:3

在我当前的项目中,我在项目的

libs
目录中添加了一个
app
文件夹。在库内,我添加了 .aar 格式的 SDK。但目前的问题是,当我将所有更新推送到 git 存储库时,除了
libs
文件夹之外,所有更新都完美推送。但我需要将该 libs 文件夹推送到 git 存储库。我将如何能够做到这一点。这是我的
.gitignore
文件 -

# Built application files
*.apk
*.aar
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/
#  Uncomment the following line in case you need and you don't have the release build type files in your app
# release/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/misc.xml
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
.idea/

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# Version control
vcs.xml

# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/

我现在应该做什么来解决这个问题?

android git gitignore
3个回答
1
投票

你可以尝试:

git add --force <path_to_libs>

或添加到.gitignore:

!<path_to_libs>

“!”使 git 不忽略库,因为默认情况下它是忽略的。


0
投票

那个

.gitignore
文件到底与Android Studio有什么关系?

提供本地 AAR 依赖项的唯一方法是本地

flatDir
存储库。


0
投票

我们需要在 gitIgnore 文件中添加一些行来忽略 GitHub 上的特定文件和文件夹推送

这是android项目的gitIgnore文件:-

#built application files
*.apk
*.ap_
*.aab
                           
# files for the dex VM
*.dex
                            
# Java class files
*.class
                            
# generated files
bin/
gen/
                            
# Local configuration file (sdk path, etc)
local.properties
                        
# Windows thumbnail db
Thumbs.db
                
# OSX files
.DS_Store
                            
# Android Studio
*.iml
.idea
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle
build/
.navigation
captures/
output.json 
    
#NDK
obj/
.externalNativeBuild

如果这些文件仍然显示在提交部分,那么这里是一些其他文件和文件夹。然后添加这些行:-

*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
© www.soinside.com 2019 - 2024. All rights reserved.