0

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.

An SO User
  • 24,612
  • 35
  • 133
  • 221

2 Answers2

1

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.

Community
  • 1
  • 1
nhaarman
  • 98,571
  • 55
  • 246
  • 278
  • Nope, initial commit. Please also tell me, in one sentence, why you chose to ignore these files – An SO User Jul 17 '14 at 07:01
  • All of these files are generated by Android studio, and are not required to import the project in a new setup. The overall result is just a result of continuous improvement. – nhaarman Jul 17 '14 at 07:02
  • I have added two more lines, I'm not *entirely* sure this covers all Eclipse stuff. – nhaarman Jul 17 '14 at 07:04
  • and why the two `**` before bin? I can understand afterwards :) – An SO User Jul 17 '14 at 07:04
  • Android Studio does not have the `bin` folders at the root level. This also ignores all `bin` folders recursively. – nhaarman Jul 17 '14 at 07:06
1

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
Marius
  • 810
  • 7
  • 20
  • Okay and what about the external dependencies that I have? I do not want them to be pushed :) – An SO User Jul 17 '14 at 07:11
  • I think Eclipse might be stupid and ignore the `.gitignore` file. I use git in terminal and vimdiff for diff, never used eclipse git. – Marius Jul 17 '14 at 07:11
  • Dependencies should belong in other repo, shouldn't they? – Marius Jul 17 '14 at 07:12
  • had to refresh the project cause the edit was made using notepad. Now the issue of external dependencies remains. I know dependencies should not be pushed to the repo. – An SO User Jul 17 '14 at 07:12
  • err.. to simplify, I have some libraries projects that I have added. How do I deal with them? *I am new to Git, sorry* – An SO User Jul 17 '14 at 07:14
  • In `libs`? If yes, they should be included. But if you insist, just add something like this `libs/` – Marius Jul 17 '14 at 07:16
  • FacebookSDK doesnt come up in `libs`, does it ? :) – An SO User Jul 17 '14 at 07:16
  • It should stay in it's own project. Git normally works in only one folder and it's children. If your parent folder includes both your application and FacebookSDK, then you should fix that. Move facebookSDK and your app into their own separate folders, and place .git repo folder inside you app folder, not in parent. – Marius Jul 17 '14 at 07:22
  • They are in different folders. Okay so no hassles there. Thank you. Now off to buy a good book on Git :) For a beginner, you would advise that I avoid GUI and stick with terminal? :) – An SO User Jul 17 '14 at 07:24
  • 1
    @LittleChild I don't think you should buy a book on git. It's enough using it in terminal. Before using, visit their website and do tutorials and you're ready. Also, terminal suggests you available commands if you misspell something. Also, you can refer to manual inside terminal on how to use any command. – Marius Jul 17 '14 at 10:55