Eclipse Git gitignore file is ignored - android

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

Related

Android-Studio (Git): *.iml file always gets committed, why?

I am developing an app using Android-Studio. To version-control my code, I am using GitLab. So, I've created the following .gitignore file to avoid committing everything:
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# built native files (uncomment if you build your own)
# *.o
# *.so
# generated files
bin/
gen/
# Ignore gradle files
.gradle/
build/
# Crashlytics configuations
com_crashlytics_export_strings.xml
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Signing files
.signing/
# Eclipse Metadata
.metadata/
# Mac OS X clutter
*.DS_Store
# Windows clutter
Thumbs.db
# Intellij IDEA (see https://intellij-support.jetbrains.com/entries/23393067)
.idea/workspace.xml
.idea/libraries/
.idea/tasks.xml
.idea/.name
.idea/compiler.xml
.idea/copyright/profiles_settings.xml
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/scopes/scope_settings.xml
.idea/vcs.xml
.idea/datasources.xml
.idea/dataSources.ids
*.iml
build/intermediates/dex-cache/cache.xml
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
However, whenever I try to commit-changes, the commit includes the build folder and .iml file (highlighted in the attached image), even though they are stated in the .gitignore file.
How to make Android-studio ignore these files and folders ?!
To get Intellij IDEA (and by extension, Android Studio) to completely ignore files and folders use the following in Editor -> File Types -> Ignore Files and Folders:
From https://www.jetbrains.com/help/idea/2016.2/file-types.html:
Ignore files and folders : In this text box, specify the files and
folders, which you want to be ignored by IntelliJ IDEA. Such files and
folders will be completely excluded from any kind of processing. By
default the list includes temporary files, service files related to
version control systems, etc.
Try This one
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"
Complete Answer here

Files to exclude from GIT for Android Studio Gradle Project to maintain the code in MAC as well as Windows.?

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.

Which files are to be saved GitHub for an Android Project?

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?

Committing an Android Project to GitHub

I am committing my first Android project to GitHub by following this video. I know that the bin and gen folders must be ignored. Using Eclipse, I did add them to the ignore file.
Now when I
Right Click on Project - Team - Commit
The window that comes up shows me the files in "bin" and "res" also. I can uncheck them, that is fine, but will I have to do this silly exercise again and again or maybe I am not understanding something.
Use this for your Android projects. Taken from github gitignore page
# 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
Copy and paste this into your .gitignore file:
.settings/org.eclipse.jdt.core.prefs
*/.settings/org.eclipse.jdt.core.prefs
**/bin/*
**/gen/*
**/build/*
**/.idea/*
**/*.iml
.gradle
/local.properties
/.idea/workspace.xml
.DS_Store
.metadata/*
This setup will ignore the irrelevant files and folders.
If you have already committed some of these files, take a look at Ignore files that have already been committed to a Git repository.

Why can't ignore some files?

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.

Categories

Resources