Wednesday, 6 June 2012

Ignoring files in the git repository for Android

One of the best options of Git is it can selectively ignoring files uploaded in the repository. This is specially useful for the binary files such as android apk file or class files in Java.

The easiest way to set it is creates an .gitignore file. This file could be placed in the git root directory to be applied for the whole repository or/and placed in the specific folder directory to be applied for a specific folder.

1. Creates .gitignore file
1.1 Open the Terminal
1.2 Go to the directory where your local version of the project is stored
1.3 Type

touch .gitignore

Now, you can open it with and text edit program, such as nano

nano .gitignore

2. Edit .gitignore file
This file has some specific syntax that should be followed:
- The default directory is the directory where the file has been stored.
- The child folders will follow the same rule, at least they have their own gitignore files.
- The comments starts with "#"
- * could be used to denote any character
- The folder should finishes with "/"
- A blank line does not introduce any rule
- The "!" could be used to indicad the negation

You might find more rules with the follow command:

man gitignore

Here is an example of gitignore file for Android:

# built application files

# files for the dex VM

# Java class files

# generated files

# Local configuration file (sdk path, etc)

Note: For Mac users, you might have to include the follow rule for mac meta file:

# Exclude OS X folder attributes

No comments:

Post a Comment