Git commands executes in root directory

Hi, i found very strange bug. I'm using Rails 4.2.0 and Travis-CI with Docker builds.

And when codeclimate tests reporter try to gather some git data, its fails with:

```
Coverage report generated for RSpec to /home/travis/build/Strech/terminal/coverage. 1668 / 1700 LOC (98.12%) covered.
Coverage = 98.12%. fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
```

I'm start digg in, and found, that codeclimate test reporter, on a gather moment have `pwd` in `/tmp` directory

```
Coverage report generated for RSpec to /home/travis/build/Strech/terminal/coverage. 1668 / 1700 LOC (98.12%) covered.
Coverage = 98.12%. fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
"PWD = /tmp\n" <------------------------------------
"root of Rails = /home/travis/build/Strech/terminal" <------------------------------------
```

This request try to change git execution directory on Rails root, or use current, as it was before.
`Dir.chdir` is not threadsafe, I don't know the implications in this case matter but I'd rather not use it. You can tell the `git` command where the git directory is by using something like this:

`git --git-dir=#{root_dir}/.git rev-parse ...`

What do you think about changing that ugly `rescue nil` with something more like `if defined?(Rails) ... else ...`