1.I am new to GitHub & working on an Android project. My question is, which files are to be saved/which not on GitHub for an Android project (Eclipse)?
2.How to delete that folder from Github using Eclipse?
copy this to your .gitignore file
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
#Log Files
*.log
for deleting that folder use these commands
git rm -r one-of-the-directories
git commit -m "Remove duplicated directory"
git push origin master
or check this [solution]: How to remove a directory from git repository?
Related
In my current project, I've added a libs folder inside my project's app directory. inside the libs, I've added an SDK in .aar format. But currently, the problem is that, when I push all my updates into a git repo, all of my updates pushed perfectly, except that libs folder. But I need to push that libs folder to the git repo. How I will able to do that. Here is my .gitignore file -
# 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/
What should I do now to resolve this issue?
You can try:
git add --force <path_to_libs>
or add in .gitignore:
!<path_to_libs>
the "!" makes git do not ignore libs, as by default it is ignoring.
And how exactly is that .gitignore file related to Android Studio ??
The only way to provide a local AAR dependency is a local flatDir repository.
I code in MAC - OSX and my partner codes in PC - Windows but when I commit and push changes there are multiple files in project directories ending with .IML or .config or .properties, which gets overwritten and cause frequent overwrites which is a nuisance.
So my question is which files can be excluded from GIT for Android Studio Gradle Project to maintain the code in MAC as well as Windows? and what is the best way to do it ?
Here is a decent .gitignore file which you put in the root directory of your project, e.g. the folder where the .git folder is:
#built application files
*.apk
*.ap_
# 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
# Eclipse project files
.classpath
.project
# Android Studio
*.iml
.idea/
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle/
build/
app/build/
gradle/
#NDK
obj/
Then you execute the following commands to apply the .gitignore:
git rm -r --cached .
git add .
git commit -m "fixed untracked files"
See more here.
EDIT: I also recommend using the .gitignore plugin for Android Studio.
I have just sync my GitHub with Android Studio and I create a new project. I want to push it in my git repository. Last time when I did this with my previous android project, I saw that some foldres like .idea, gradle and other files out of the app folder are never updated again. They are staying like the first commit. So tell me - which folders I have to upload for full application without any missing recourse and others? Thanks again.
Typical gitignore file for an android project :
#built application files
*.apk
*.ap_
# 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
# Eclipse project files
.classpath
.project
# Android Studio
.idea
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle
build/
You can find sample .gitignore files in GitHub's gitignore repository. The one for Android is:
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
You can also add your IDE related files and directories to this .gitignore file. For example for Android Studio:
# Android Studio
*.iml
*.ipr
*.iws
.idea/
This is my .gitignore for my Android Studio
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
build/
# Local configuration file (sdk path, etc)
local.properties
# Eclipse project files
.classpath
.project
# Android Studio
.idea/
.gradle
*.iml
.DS_Store
When I clean my project,it appears some files
How to modify .gitignore to ignore the files?
From your local path for git repo (which I am assuming here is ~/Documents/project_android)
add path to ignore.
#Cookie Files
Cookies3/*
and save
add
folderToRemove/
OR
*.FileFormat to remove
The build/ rule should already ignore those files.
.gitignore won't ignore objects already added to the index. Use git rm --cached <filename> to remove a file from the index but not from the working tree.
I have an Android project in which I wish GIT to ignore the bin and gen folders. Therefore, I have placed in the directory of the project (I have also tried it at a level higher) the following .gitignore file:
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Eclipse project files
#.classpath
#.project
Unfortunately, this file is being ignored by Eclipse and I keep committing .class files and files from both gen/ and bin/. I have also tried to mark the folders as "Assume unchanged" but that also does not help.
I am not sure, but it is possible that I have added the file AFTER the first commit.
Seems like you have already added and committed the gen and bin directories. .gitignore works only for untracked files and the purpose of it is to ensure purportedly untracked files remain untracked. To stop tracking bin and gen:
git rm -r --cached bin gen
git commit -m "removed generated files"
I had to add additional file structure:
git rm -r --cached ./projectname/bin
but this definitely helped this situation