Add GIT_DIR variable checking

From [Git documentation](http://git-scm.com/docs/git.html):
```
If the GIT_DIR environment variable is set then it
specifies a path to use instead of the default
.git for the base of the repository.
```