2

I have an android project developed in Eclipse with the ADT plugin. I want to add it to git and finally host it on github. But i am confused as to which all files will need to be added to git to make it easy for other developers to work on the project.

Obviously, the following needs to be added :

  1. src folder
  2. res folder
  3. AndroidManifest.xml
  4. proguard-project.txt
  5. project.properties

But i see other files/directories in my project folder, which i am not sure about :

.classpath
.project
bin/
gen/
proguard/

Can i skip these and expect the other developers to successfully recreate the project to work-on/build it?

faizal
  • 3,497
  • 7
  • 37
  • 62
  • Hello! .classpath YES .project YES bin/ NO (Eclipse recreate it automatically) gen/ NO (same) proguard/ YES – Tristan Jul 23 '14 at 05:37
  • @Tristan why is `proguard/` required? Won't it be generated by Eclipse automatically when another developer tries to build it? – faizal Jul 23 '14 at 05:41
  • you are right! proguard is also not needed as generated by eclipse =) My bad! – Tristan Jul 23 '14 at 05:47
  • @Tristan thanks. the other answers seem to suggest `.classpath` and `.project` are not required either. Do you think they are required for other developers to successfully recreate the project? – faizal Jul 23 '14 at 05:52
  • 1
    Of course .project and .classpath should be indexed with git... .project allow eclipse to find the project to import .classpath defines dependencies with the project Note : I'm talking about needed file to import the project, not to recreate it with the sources – Tristan Jul 23 '14 at 05:56

3 Answers3

2

This is the .gitignore file that I use with android projects. You can use the same. .classpath and .project are eclipse project files that other developers don't need. bin/ and gen/ are generated files and will be generated automatically when someone builds the project so they can be left out. The proguard/ directory is also generated every time you build in release mode and can be left out.

# 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
.settings

# Proguard folder generated by Eclipse
proguard/

# Intellij project files
*.iml
*.ipr
*.iws
.idea/
sej101
  • 225
  • 2
  • 11
  • Do i manually create this file in my local project folder before using `git add`? – faizal Jul 23 '14 at 05:46
  • 1
    yup, stick it in your top level directory where you initialised your git repository (same place as where you find .git). If you use github to initialise the repository then there is an option to create a .gitignore file. It will ask you the type of project (choose android) and it will automatically add the file with all the rules. – sej101 Jul 23 '14 at 05:48
  • ok. but if i don't include the `.classpath` and `.project` files in git, can other developers recreate the same project on their Eclipse? Wouldn't it make sense to include them as well? – faizal Jul 23 '14 at 05:51
  • Other developers can create an eclipse project by importing your source code. Eclipse will create a .classpath and .project file for them which means they will be free to use other options and preferences which won't interfere with whoever else is contributing to the project. And this is assuming they are using ADT and not android studio – sej101 Jul 23 '14 at 05:55
  • 1
    Okay after checking a bit, I think I might be wrong. Check this for more opinions http://stackoverflow.com/questions/2818239/classpath-and-project-check-into-version-control-or-not – sej101 Jul 23 '14 at 06:00
  • That makes sense. thanks. I will include `.classpath` and `.project` as well to keep things simple. – faizal Jul 23 '14 at 06:06
  • On second thought, is this `.gitignore` file really required? i am using `git add` to select the files i want to add right? So this file becomes redundant? – faizal Jul 23 '14 at 06:18
  • 1
    Well if you want to use "git add filename" for every file that you add then yes .gitignore is a bit redundant. But if you add a whole bunch of files and want to do "git add ." (to add all the files at once) then it won't add the files in .gitignore. Similarly "git status" won't keep bothering you about untracked files. It is simply more convenient. – sej101 Jul 23 '14 at 06:25
  • sounds good. I think adding the `.gitignore` file itself into the git repository would also be a good idea then, so that other developers don't worry about checking in unnecessary files by mistake. Is that a usual practice? I could not find any such suggestion at http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository#Ignoring-Files – faizal Jul 23 '14 at 07:18
  • 1
    Yes! It is standard practice to add .gitignore to your repository and to commit any changes to it. – sej101 Jul 23 '14 at 07:26
1

Check this .gitignore file from Google I/O App. This is what I use for my projects

However this is mainly intented to the Gradle based Android projects (for IDEs Android Studio, IntelliJ IDEA and Eclipse) it'll work very well with traditional Ant based projects too.

gnuanu
  • 2,252
  • 3
  • 29
  • 42
0

Set up your local directory

    mkdir /path/to/your/project
    cd /path/to/your/project
    git init
    git remote add origin git@server.org:urproject/monikacodes.git

Create your first file, commit, and push

echo "ur_name" >> contributors.txt
git add contributors.txt
git commit -m 'Initial commit with contributors'
git push -u origin master

then u can commit remaining source code :

git status
git add --all
git commit -m "commit message"
git push origin HEAD:refs/for/master
KOTIOS
  • 11,177
  • 3
  • 39
  • 66